Class StructuredGraph

java.lang.Object
jdk.graal.compiler.graph.Graph
jdk.graal.compiler.nodes.StructuredGraph
All Implemented Interfaces:
EventCounter, JavaMethodContext

public final class StructuredGraph extends Graph implements 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.
  • Field Details

  • Method Details

    • isLastScheduleValid

      public boolean isLastScheduleValid()
      Returns true if the graph has not changed since calculating the last schedule. Use getLastSchedule() for obtaining the cached schedule.
    • isLastCFGValid

      public boolean isLastCFGValid()
      Returns true if the graph has not changed since calculating the last control flow graph. Use getLastCFG() for obtaining the cached cfg.
    • setLastSchedule

      public void setLastSchedule(StructuredGraph.ScheduleResult result)
    • getLastSchedule

      public StructuredGraph.ScheduleResult getLastSchedule()
      Returns the last schedule which has been computed for this graph. Use isLastScheduleValid() to verify that the graph has not changed since the last schedule has been computed.
    • clearLastSchedule

      public void clearLastSchedule()
    • getLastCFG

      public ControlFlowGraph getLastCFG()
      Returns the last control flow graph which has been computed for this graph. Use isLastCFGValid() to verify that the graph has not changed since the last cfg has been computed. Creating a ControlFlowGraph via ControlFlowGraphBuilder.build() will implicitly return and/or update the cached cfg.
    • setLastCFG

      public void setLastCFG(ControlFlowGraph cfg)
    • clearLastCFG

      public void clearLastCFG()
    • getDebugProperties

      public void getDebugProperties(Map<Object,Object> properties)
      Description copied from class: Graph
      Add any per graph properties that might be useful for debugging (e.g., to view in the ideal graph visualizer).
      Overrides:
      getDebugProperties in class Graph
    • beforeNodeDuplication

      public void beforeNodeDuplication(Graph sourceGraph)
      Description copied from class: Graph
      This is called before nodes are transferred to sourceGraph by NodeClass.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 class Graph
      Parameters:
      sourceGraph - the source of the nodes that were duplicated
    • beforeNodeIdChange

      protected Object beforeNodeIdChange(Node node)
      Overrides:
      beforeNodeIdChange in class Graph
    • afterNodeIdChange

      protected void afterNodeIdChange(Node node, Object value)
      Overrides:
      afterNodeIdChange in class Graph
    • compress

      protected boolean compress(boolean minimizeSize)
      Overrides:
      compress in class Graph
    • toString

      public String toString()
      Overrides:
      toString in class Graph
    • start

      public StartNode 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

      public GraphState getGraphState()
    • getGuardsStage

      public GraphState.GuardsStage getGuardsStage()
      Returns the guards stage of this graph. See GraphState.getGuardsStage().
    • getSpeculationLog

      public jdk.vm.ci.meta.SpeculationLog getSpeculationLog()
      Returns the SpeculationLog for this graph. See GraphState.getSpeculationLog().
    • isBeforeStage

    • isAfterStage

    • getCancellable

      public Cancellable getCancellable()
    • checkCancellation

      public void checkCancellation()
    • isOSR

      public boolean isOSR()
    • graphId

      public long graphId()
    • compilationId

      public CompilationIdentifier compilationId()
      See Also:
    • setStart

      public void setStart(StartNode start)
    • getInliningLog

      public InliningLog getInliningLog()
      Gets the inlining log associated with this graph. This will return null iff GraalOptions.TraceInlining is false in Graph.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 for invoke. An inlining decision can be either positive or negative. A positive inlining decision must be logged after replacing an Invoke with a graph. In this case, the node replacement map and the InliningLog of the inlined graph must be provided.
      Parameters:
      invoke - the invocation to which the inlining decision pertains
      positive - true if the invocation was inlined, false otherwise
      phase - name of the phase doing the inlining
      replacements - the node replacement map used by inlining, ignored if positive == false
      calleeInliningLog - the inlining log of the inlined graph, ignored if positive == false
      calleeOptimizationLog - the optimization log of the inlined graph, ignored if positive == false
      inlineeMethod - the actual method considered for inlining
      reason - format string that along with args 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 class Graph
      Parameters:
      newName - the name of the copy, used for debugging purposes (can be null)
      duplicationMapCallback - consumer of the duplication map created during the copying
      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(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 copying
      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).
      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 additional newAssumptions 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

      public ParameterNode getParameter(int index)
    • getInvokes

      public Iterable<Invoke> getInvokes()
    • hasLoops

      public boolean hasLoops()
    • removeFixed

      public void removeFixed(FixedWithNextNode node)
      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

      public void replaceFixed(FixedWithNextNode node, Node replacement)
    • replaceFixedWithFixed

      public void replaceFixedWithFixed(FixedWithNextNode node, FixedWithNextNode replacement)
    • replaceFixedWithFloating

      public void replaceFixedWithFloating(FixedWithNextNode node, ValueNode replacement)
    • removeSplit

      public void removeSplit(ControlSplitNode node, AbstractBeginNode survivingSuccessor)
    • removeSplitPropagate

      public void removeSplitPropagate(ControlSplitNode node, AbstractBeginNode survivingSuccessor)
    • 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

      public void replaceWithExceptionSplit(WithExceptionNode node, WithExceptionNode replacement)
    • addAfterFixed

      public void addAfterFixed(FixedWithNextNode node, FixedNode newNode)
    • addBeforeFixed

      public void addBeforeFixed(FixedNode node, FixedWithNextNode newNode)
    • reduceDegenerateLoopBegin

      public void reduceDegenerateLoopBegin(LoopBeginNode begin)
    • reduceDegenerateLoopBegin

      public void reduceDegenerateLoopBegin(LoopBeginNode begin, boolean forKillCFG)
    • reduceTrivialMerge

      public void reduceTrivialMerge(AbstractMergeNode merge)
    • reduceTrivialMerge

      public void reduceTrivialMerge(AbstractMergeNode merge, boolean forKillCFG)
    • getProfileProvider

      public ProfileProvider getProfileProvider()
      Return the ProfileProvider 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 by Snippet. 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 the getProfileProvider().
    • 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

      public StructuredGraph.AllowAssumptions allowAssumptions()
      Returns the AllowAssumptions status for this graph.
      Returns:
      AllowAssumptions.YES if this graph allows recording assumptions, AllowAssumptions.NO otherwise
    • recordAssumptions

      public void recordAssumptions(StructuredGraph inlineGraph)
    • isRecordingInlinedMethods

      public boolean isRecordingInlinedMethods()
    • getMethods

      public List<jdk.vm.ci.meta.ResolvedJavaMethod> 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 that method was used to build this graph.
    • updateMethods

      public void updateMethods(StructuredGraph other)
      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 interface JavaMethodContext
    • hasUnsafeAccess

      public boolean hasUnsafeAccess()
    • markUnsafeAccess

      public void markUnsafeAccess(Class<? extends TrackedUnsafeAccess> nodeClass)
      Records that this graph encodes a memory access via the Unsafe 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

      public void maybeMarkUnsafeAccess(EncodedGraph graph)
    • maybeMarkUnsafeAccess

      public void maybeMarkUnsafeAccess(StructuredGraph graph)
    • 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

      protected void afterRegister(Node node)
      Overrides:
      afterRegister in class Graph
    • getOptimizationLog

      public OptimizationLog getOptimizationLog()
    • setGlobalProfileProvider

      public void setGlobalProfileProvider(StructuredGraph.GlobalProfileProvider globalProfileProvider)
    • globalProfileProvider

      public StructuredGraph.GlobalProfileProvider globalProfileProvider()
      Returns:
      The current StructuredGraph.GlobalProfileProvider for this graph.
    • setOptimizationLog

      public void setOptimizationLog(OptimizationLog newOptimizationLog)
      Sets the optimization log associated with this graph. The new instance should be bound to this graph and be set up according to the options.
      Parameters:
      newOptimizationLog - the optimization log instance
    • setInliningLog

      public void setInliningLog(InliningLog newInliningLog)
      Sets the inlining log associated with this graph. The new instance should be null iff it is expected to be null according to the options.
      Parameters:
      newInliningLog - the new inlining log instance
    • verify

      public boolean verify(boolean verifyInputs)
      Overrides:
      verify in class Graph