Class StructuredGraph
java.lang.Object
jdk.graal.compiler.graph.Graph
jdk.graal.compiler.nodes.StructuredGraph
- All Implemented Interfaces:
EventCounter
,JavaMethodContext
A graph that contains at least one distinguished node : the
start
node. This
node is the start of the control flow of the graph.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Constants denoting whether or notAssumptions.Assumption
s can be made while processing a graph.static class
Object used to create aStructuredGraph
.static interface
Implementers of this interface should provideglobal profile-related information about theStructuredGraph
i.e.static class
Nested classes/interfaces inherited from class jdk.graal.compiler.graph.Graph
Graph.DuplicationReplacement, Graph.Mark, Graph.NodeEvent, Graph.NodeEventListener, Graph.NodeEventScope, Graph.Options
Nested classes/interfaces inherited from interface jdk.graal.compiler.core.common.util.EventCounter
EventCounter.EventCounterMarker
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final boolean
static final boolean
Fields inherited from class jdk.graal.compiler.graph.Graph
name, trackNodeSourcePosition, verifyGraphEdges, verifyGraphs
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAfterFixed
(FixedWithNextNode node, FixedNode newNode) void
addBeforeFixed
(FixedNode node, FixedWithNextNode newNode) protected void
afterNodeIdChange
(Node node, Object value) protected void
afterRegister
(Node node) Returns the AllowAssumptions status for this graph.jdk.vm.ci.meta.JavaMethod
void
beforeNodeDuplication
(Graph sourceGraph) This is called before nodes are transferred tosourceGraph
byNodeClass.addGraphDuplicate(jdk.graal.compiler.graph.Graph, jdk.graal.compiler.graph.Graph, int, java.lang.Iterable<? extends jdk.graal.compiler.graph.Node>, jdk.graal.compiler.graph.Graph.DuplicationReplacement)
to allow the transfer of any other state which should also be transferred.protected Object
beforeNodeIdChange
(Node node) void
void
For use in tests to clear all stateAfter frame states.void
void
protected boolean
compress
(boolean minimizeSize) protected Graph
copy
(String newName, Consumer<org.graalvm.collections.UnmodifiableEconomicMap<Node, Node>> duplicationMapCallback, DebugContext debugForCopy) Creates a copy of this graph.copy
(String newName, Consumer<org.graalvm.collections.UnmodifiableEconomicMap<Node, Node>> duplicationMapCallback, DebugContext debugForCopy, OptionValues options) Creates a copy of this graph with the new option values.copy
(jdk.vm.ci.meta.ResolvedJavaMethod rootMethodForCopy, List<jdk.vm.ci.meta.ResolvedJavaMethod> inlinedMethodsForCopy, OptionValues optionsForCopy, DebugContext debugForCopy, boolean trackNodeSourcePositionForCopy) copy
(jdk.vm.ci.meta.ResolvedJavaMethod rootMethodForCopy, OptionValues optionsForCopy, DebugContext debugForCopy, boolean trackNodeSourcePositionForCopy) copyWithAssumptions
(jdk.vm.ci.meta.Assumptions newAssumptions, DebugContext debugForCopy) Makes a copy of this graph, recording both this graph's assumptions (if any) and the additionalnewAssumptions
in it.copyWithIdentifier
(CompilationIdentifier newCompilationId, DebugContext debugForCopy) void
jdk.vm.ci.meta.Assumptions
Gets the object for recording assumptions while constructing of this graph.int
Gets the input bytecode size from which this graph is constructed.void
getDebugProperties
(Map<Object, Object> properties) Add any per graph properties that might be useful for debugging (e.g., to view in the ideal graph visualizer).int
Returns the guards stage of this graph.Gets the inlining log associated with this graph.Returns the last control flow graph which has been computed for this graph.Returns the last schedule which has been computed for this graph.List
<jdk.vm.ci.meta.ResolvedJavaMethod> Gets an unmodifiable view of the methods that were inlined while constructing this graph.getParameter
(int index) Return theProfileProvider
in use for the graph.jdk.vm.ci.meta.ProfilingInfo
Gets the profiling info for the root method of this graph.jdk.vm.ci.meta.ProfilingInfo
getProfilingInfo
(jdk.vm.ci.meta.ResolvedJavaMethod m) Gets the profiling info for a given method that is or will be part of this graph, taking into account thegetProfileProvider()
.jdk.vm.ci.meta.SpeculationLog
Returns theSpeculationLog
for this graph.long
graphId()
boolean
hasLoops()
boolean
boolean
boolean
isAfterStage
(GraphState.StageFlag stage) boolean
boolean
Returnstrue
if the graph has not changed since calculating the last control flow graph.boolean
Returnstrue
if the graph has not changed since calculating the last schedule.boolean
isOSR()
boolean
boolean
Returns true if this graph is built without parsing the root method or if the root method is annotated bySnippet
.boolean
void
void
markUnsafeAccess
(Class<? extends TrackedUnsafeAccess> nodeClass) Records that this graph encodes a memory access via theUnsafe
class.void
void
jdk.vm.ci.meta.ResolvedJavaMethod
method()
Gets the root method from which this graph was built.void
notifyInliningDecision
(Invokable invoke, boolean positive, String phase, org.graalvm.collections.EconomicMap<Node, Node> replacements, InliningLog calleeInliningLog, OptimizationLog calleeOptimizationLog, jdk.vm.ci.meta.ResolvedJavaMethod inlineeMethod, String reason, Object... args) Notifies this graph of an inlining decision forinvoke
.void
recordAssumptions
(StructuredGraph inlineGraph) void
recordMethod
(jdk.vm.ci.meta.ResolvedJavaMethod method) Records thatmethod
was used to build this graph.void
void
reduceDegenerateLoopBegin
(LoopBeginNode begin, boolean forKillCFG) void
void
reduceTrivialMerge
(AbstractMergeNode merge, boolean forKillCFG) void
removeFixed
(FixedWithNextNode node) Unlinks a node from all its control flow neighbors and then removes it from its graph.void
removeSplit
(ControlSplitNode node, AbstractBeginNode survivingSuccessor) void
removeSplitPropagate
(ControlSplitNode node, AbstractBeginNode survivingSuccessor) void
replaceFixed
(FixedWithNextNode node, Node replacement) void
replaceFixedWithFixed
(FixedWithNextNode node, FixedWithNextNode replacement) void
replaceFixedWithFloating
(FixedWithNextNode node, ValueNode replacement) void
replaceSplit
(ControlSplitNode node, Node replacement, AbstractBeginNode survivingSuccessor) void
replaceSplitWithFixed
(ControlSplitNode node, FixedWithNextNode replacement, AbstractBeginNode survivingSuccessor) void
replaceSplitWithFloating
(ControlSplitNode node, FloatingNode replacement, AbstractBeginNode survivingSuccessor) void
replaceWithExceptionSplit
(WithExceptionNode node, WithExceptionNode replacement) void
setGlobalProfileProvider
(StructuredGraph.GlobalProfileProvider globalProfileProvider) Set aglobal profile provider
for thisgraph
.void
setInliningLog
(InliningLog newInliningLog) Sets the inlining log associated with this graph.void
void
void
setOptimizationLog
(OptimizationLog newOptimizationLog) Sets the optimization log associated with this graph.void
start()
toString()
void
updateMethods
(StructuredGraph other) Updates the methods used to build this graph with the methods used to build another graph.boolean
verify
(boolean verifyInputs) Methods inherited from class jdk.graal.compiler.graph.Graph
add, addDuplicates, addDuplicates, addOrUnique, addOrUniqueWithInputs, addOrUniqueWithInputs, addWithoutUnique, addWithoutUniqueWithInputs, afterDecodingFields, beforeDecodingFields, copy, copy, createIterativeNodeWorkList, createNodeBitMap, createNodeFlood, createNodeMap, createNodeWorkList, currentNodeSourcePosition, eventCounterOverflows, eventCounterToString, findDuplicate, findDuplicate, fireNodeEvent, freeze, getCompressions, getDebug, getEdgeModificationCount, getEventCounter, getEventCounterMarker, getMark, getNewNodes, getNode, getNodeCount, getNodes, getNodes, getNodesDeletedSinceLastCompression, getOptions, getTotalNodesDeleted, hasNode, isFrozen, isNew, isNodeModificationCountsEnabled, maybeCompress, nodeIdCount, resetDebug, setTrackNodeSourcePosition, temporaryFreeze, trackNodeEvents, trackNodeSourcePosition, trackNodeSourcePositionDefault, unfreeze, unique, verify, verifySourcePositions, withNodeSourcePosition, withNodeSourcePosition
-
Field Details
-
USE_PROFILING_INFO
public static final boolean USE_PROFILING_INFO- See Also:
-
NO_PROFILING_INFO
public static final boolean NO_PROFILING_INFO- See Also:
-
-
Method Details
-
isLastScheduleValid
public boolean isLastScheduleValid()Returnstrue
if the graph has not changed since calculating the last schedule. UsegetLastSchedule()
for obtaining the cached schedule. -
isLastCFGValid
public boolean isLastCFGValid()Returnstrue
if the graph has not changed since calculating the last control flow graph. UsegetLastCFG()
for obtaining the cached cfg. -
setLastSchedule
-
getLastSchedule
Returns the last schedule which has been computed for this graph. UseisLastScheduleValid()
to verify that the graph has not changed since the last schedule has been computed. -
clearLastSchedule
public void clearLastSchedule() -
getLastCFG
Returns the last control flow graph which has been computed for this graph. UseisLastCFGValid()
to verify that the graph has not changed since the last cfg has been computed. Creating aControlFlowGraph
viaControlFlowGraphBuilder.build()
will implicitly return and/or update the cached cfg. -
setLastCFG
-
clearLastCFG
public void clearLastCFG() -
getDebugProperties
-
beforeNodeDuplication
Description copied from class:Graph
This is called before nodes are transferred tosourceGraph
byNodeClass.addGraphDuplicate(jdk.graal.compiler.graph.Graph, jdk.graal.compiler.graph.Graph, int, java.lang.Iterable<? extends jdk.graal.compiler.graph.Node>, jdk.graal.compiler.graph.Graph.DuplicationReplacement)
to allow the transfer of any other state which should also be transferred.- Overrides:
beforeNodeDuplication
in classGraph
- Parameters:
sourceGraph
- the source of the nodes that were duplicated
-
beforeNodeIdChange
- Overrides:
beforeNodeIdChange
in classGraph
-
afterNodeIdChange
- Overrides:
afterNodeIdChange
in classGraph
-
compress
-
toString
-
start
-
method
public jdk.vm.ci.meta.ResolvedJavaMethod method()Gets the root method from which this graph was built.- Returns:
- null if this method was not built from a method or the method is not available
-
getEntryBCI
public int getEntryBCI() -
getGraphState
-
getGuardsStage
Returns the guards stage of this graph. SeeGraphState.getGuardsStage()
. -
getSpeculationLog
public jdk.vm.ci.meta.SpeculationLog getSpeculationLog()Returns theSpeculationLog
for this graph. SeeGraphState.getSpeculationLog()
. -
isBeforeStage
-
isAfterStage
-
getCancellable
-
checkCancellation
public void checkCancellation() -
isOSR
public boolean isOSR() -
graphId
public long graphId() -
compilationId
- See Also:
-
setStart
-
getInliningLog
Gets the inlining log associated with this graph. This will returnnull
iffGraalOptions.TraceInlining
isfalse
inGraph.getOptions()
. -
notifyInliningDecision
public void notifyInliningDecision(Invokable invoke, boolean positive, String phase, org.graalvm.collections.EconomicMap<Node, Node> replacements, InliningLog calleeInliningLog, OptimizationLog calleeOptimizationLog, jdk.vm.ci.meta.ResolvedJavaMethod inlineeMethod, String reason, Object... args) Notifies this graph of an inlining decision forinvoke
. An inlining decision can be either positive or negative. A positive inlining decision must be logged after replacing anInvoke
with a graph. In this case, the node replacement map and theInliningLog
of the inlined graph must be provided.- Parameters:
invoke
- the invocation to which the inlining decision pertainspositive
-true
if the invocation was inlined,false
otherwisephase
- name of the phase doing the inliningreplacements
- the node replacement map used by inlining, ignored ifpositive == false
calleeInliningLog
- the inlining log of the inlined graph, ignored ifpositive == false
calleeOptimizationLog
- the optimization log of the inlined graph, ignored ifpositive == false
inlineeMethod
- the actual method considered for inliningreason
- format string that along withargs
provides the reason for decision
-
logInliningTree
public void logInliningTree() -
copy
protected Graph copy(String newName, Consumer<org.graalvm.collections.UnmodifiableEconomicMap<Node, Node>> duplicationMapCallback, DebugContext debugForCopy) Creates a copy of this graph. If a node contains an array of objects, only shallow copy of the field is applied.- Overrides:
copy
in classGraph
- Parameters:
newName
- the name of the copy, used for debugging purposes (can be null)duplicationMapCallback
- consumer of the duplication map created during the copyingdebugForCopy
- the debug context for the graph copy. This must not be the debug for this graph if this graph can be accessed from multiple threads (e.g., it's in a cache accessed by multiple threads).
-
copy
public StructuredGraph copy(String newName, Consumer<org.graalvm.collections.UnmodifiableEconomicMap<Node, Node>> duplicationMapCallback, DebugContext debugForCopy, OptionValues options) Creates a copy of this graph with the new option values. If a node contains an array of objects, only shallow copy of the field is applied.- Parameters:
newName
- the name of the copy, used for debugging purposes (can be null)duplicationMapCallback
- consumer of the duplication map created during the copyingdebugForCopy
- the debug context for the graph copy. This must not be the debug for this graph if this graph can be accessed from multiple threads (e.g., it's in a cache accessed by multiple threads).options
- the option values for the graph copy
-
copyWithIdentifier
public StructuredGraph copyWithIdentifier(CompilationIdentifier newCompilationId, DebugContext debugForCopy) - Parameters:
debugForCopy
- the debug context for the graph copy. This must not be the debug for this graph if this graph can be accessed from multiple threads (e.g., it's in a cache accessed by multiple threads).
-
copy
public StructuredGraph copy(jdk.vm.ci.meta.ResolvedJavaMethod rootMethodForCopy, OptionValues optionsForCopy, DebugContext debugForCopy, boolean trackNodeSourcePositionForCopy) -
copy
public StructuredGraph copy(jdk.vm.ci.meta.ResolvedJavaMethod rootMethodForCopy, List<jdk.vm.ci.meta.ResolvedJavaMethod> inlinedMethodsForCopy, OptionValues optionsForCopy, DebugContext debugForCopy, boolean trackNodeSourcePositionForCopy) -
copyWithAssumptions
public StructuredGraph copyWithAssumptions(jdk.vm.ci.meta.Assumptions newAssumptions, DebugContext debugForCopy) Makes a copy of this graph, recording both this graph's assumptions (if any) and the additionalnewAssumptions
in it.- Parameters:
debugForCopy
- the debug context for the graph copy. This must not be the debug for this graph if this graph can be accessed from multiple threads (e.g., it's in a cache accessed by multiple threads).
-
getParameter
-
getInvokes
-
hasLoops
public boolean hasLoops() -
removeFixed
Unlinks a node from all its control flow neighbors and then removes it from its graph. The node must have no usages.- Parameters:
node
- the node to be unlinked and removed
-
replaceFixed
-
replaceFixedWithFixed
-
replaceFixedWithFloating
-
removeSplit
-
removeSplitPropagate
-
replaceSplit
public void replaceSplit(ControlSplitNode node, Node replacement, AbstractBeginNode survivingSuccessor) -
replaceSplitWithFixed
public void replaceSplitWithFixed(ControlSplitNode node, FixedWithNextNode replacement, AbstractBeginNode survivingSuccessor) -
replaceSplitWithFloating
public void replaceSplitWithFloating(ControlSplitNode node, FloatingNode replacement, AbstractBeginNode survivingSuccessor) -
replaceWithExceptionSplit
-
addAfterFixed
-
addBeforeFixed
-
reduceDegenerateLoopBegin
-
reduceDegenerateLoopBegin
-
reduceTrivialMerge
-
reduceTrivialMerge
-
getProfileProvider
Return theProfileProvider
in use for the graph. -
isSubstitution
public boolean isSubstitution()Returns true if this graph is built without parsing the root method or if the root method is annotated bySnippet
. This is preferred over querying annotations directly as querying annotations can cause class loading. -
getProfilingInfo
public jdk.vm.ci.meta.ProfilingInfo getProfilingInfo()Gets the profiling info for the root method of this graph. -
getProfilingInfo
public jdk.vm.ci.meta.ProfilingInfo getProfilingInfo(jdk.vm.ci.meta.ResolvedJavaMethod m) Gets the profiling info for a given method that is or will be part of this graph, taking into account thegetProfileProvider()
. -
getAssumptions
public jdk.vm.ci.meta.Assumptions getAssumptions()Gets the object for recording assumptions while constructing of this graph.- Returns:
null
if assumptions cannot be made for this graph
-
allowAssumptions
Returns the AllowAssumptions status for this graph.- Returns:
AllowAssumptions.YES
if this graph allows recording assumptions,AllowAssumptions.NO
otherwise
-
recordAssumptions
-
isRecordingInlinedMethods
public boolean isRecordingInlinedMethods() -
getMethods
Gets an unmodifiable view of the methods that were inlined while constructing this graph. -
recordMethod
public void recordMethod(jdk.vm.ci.meta.ResolvedJavaMethod method) Records thatmethod
was used to build this graph. -
updateMethods
Updates the methods used to build this graph with the methods used to build another graph. -
getBytecodeSize
public int getBytecodeSize()Gets the input bytecode size from which this graph is constructed. This ignores how many bytecodes in each constituent method are actually parsed (which may be none for methods whose IR is retrieved from a cache or less than the full amount for any given method due to profile guided branch pruning). -
asJavaMethod
public jdk.vm.ci.meta.JavaMethod asJavaMethod()- Specified by:
asJavaMethod
in interfaceJavaMethodContext
-
hasUnsafeAccess
public boolean hasUnsafeAccess() -
markUnsafeAccess
Records that this graph encodes a memory access via theUnsafe
class. HotSpot requires this information to modify the behavior of its signal handling for compiled code that contains an unsafe memory access.- Parameters:
nodeClass
- the type of the node encoding the unsafe access
-
maybeMarkUnsafeAccess
-
maybeMarkUnsafeAccess
-
disableUnsafeAccessTracking
public void disableUnsafeAccessTracking() -
isUnsafeAccessTrackingEnabled
public boolean isUnsafeAccessTrackingEnabled() -
clearAllStateAfterForTestingOnly
public void clearAllStateAfterForTestingOnly()For use in tests to clear all stateAfter frame states. -
hasVirtualizableAllocation
public boolean hasVirtualizableAllocation() -
afterRegister
- Overrides:
afterRegister
in classGraph
-
getOptimizationLog
-
setGlobalProfileProvider
Set aglobal profile provider
for thisgraph
. -
globalProfileProvider
- Returns:
- The current
StructuredGraph.GlobalProfileProvider
for this graph.
-
setOptimizationLog
Sets the optimization log associated with this graph. The new instance should be bound to this graph and be set up according to theoptions
.- Parameters:
newOptimizationLog
- the optimization log instance
-
setInliningLog
Sets the inlining log associated with this graph. The new instance should benull
iff it is expected to benull
according to theoptions
.- Parameters:
newInliningLog
- the new inlining log instance
-
verify
-