Class OptimizedCallTarget
java.lang.Object
com.oracle.truffle.runtime.OptimizedCallTarget
- All Implemented Interfaces:
com.oracle.truffle.api.CallTarget,com.oracle.truffle.api.ReplaceObserver,com.oracle.truffle.api.RootCallTarget,com.oracle.truffle.compiler.TruffleCompilable
- Direct Known Subclasses:
HotSpotOptimizedCallTarget
public abstract class OptimizedCallTarget
extends Object
implements com.oracle.truffle.compiler.TruffleCompilable, com.oracle.truffle.api.RootCallTarget, com.oracle.truffle.api.ReplaceObserver
Call target that is optimized by Graal upon surpassing a specific invocation threshold. That is,
this is a Truffle AST that can be optimized via partial evaluation and compiled to machine code.
Note:
PartialEvaluator looks up this class and a number of its methods by name.
The end-goal of executing a OptimizedCallTarget is executing its root node. The following
call-graph shows all the paths that can be taken from calling a call target (through all the
public call* methods) to the
execution of the root node
depending on the type of call.
OptimizedRuntimeSupport#callProfiled OptimizedRuntimeSupport#callInlined
| |
| V
PUBLIC call -> callIndirect | callOSR callDirect <================> callInlined
| +-+ | | ^ |
| | +---+ | substituted by the |
V V V | compiler if inlined |
PROTECTED doInvoke <-------------+ |
| |
| <= Jump to installed code |
V |
PROTECTED callBoundary |
| |
| <= Tail jump to installed code in Int. |
V |
PROTECTED profiledPERoot |
| |
PRIVATE +----------> executeRootNode <---------------------+
|
V
rootNode.execute()
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final class -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal EngineDataThe engine data associated with this call target.final longprotected booleanWhether this call target was cloned, compiled or called.protected jdk.vm.ci.meta.SpeculationLogThe speculation log to keep track of assumptions taken and failed for previous compilations. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedOptimizedCallTarget(EngineData engine) protectedOptimizedCallTarget(OptimizedCallTarget sourceCallTarget, com.oracle.truffle.api.nodes.RootNode rootNode) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaccept(com.oracle.truffle.api.nodes.NodeVisitor visitor) final jdk.vm.ci.meta.JavaConstantfinal Objectfinal Objectprotected final ObjectcallBoundary(Object[] args) final ObjectcallDirect(com.oracle.truffle.api.nodes.Node location, Object... args) In compiled code, this is only used if the callee is not inlined.final ObjectcallIndirect(com.oracle.truffle.api.nodes.Node location, Object... args) final ObjectcallInlined(com.oracle.truffle.api.nodes.Node location, Object... arguments) final ObjectbooleancancelCompilation(CharSequence reason) final booleancompile(boolean lastTierCompilation) Returnstrueif the call target was already compiled or was compiled synchronously.final booleanComputes block compilation usingBlockNodeAPIs.intstatic com.oracle.truffle.api.impl.FrameWithoutBoxingcreateFrame(com.oracle.truffle.api.frame.FrameDescriptor descriptor, Object[] args) Intrinsifiable compiler directive for creating a frame.final voidWe intentionally do not synchronize here since as it's not worth the sync costs.protected ObjectOverridden by SVM.longengineId()final booleanfinal intfinal intfinal OptimizedDirectCallNodeabstract longGets the address of the machine code for this call target.protected final OptimizedCallTarget.ArgumentsProfileprotected final OptimizedCallTarget.ReturnProfilefinal longfinal intfinal StringgetName()final intfinal <T> TgetOptionValue(org.graalvm.options.OptionKey<T> key) final org.graalvm.options.OptionValuesfinal com.oracle.truffle.api.nodes.RootNodefinal OptimizedDirectCallNodefinal OptimizedCallTargetjdk.vm.ci.meta.SpeculationLogGets the speculation log used to collect all failed speculations in the compiled code for this call target.final inthashCode()final intfinal booleaninvalidate(CharSequence reason) Invalidates this call target by invalidating any machine code attached to it.final booleanfinal booleanisSameOrSplit(com.oracle.truffle.compiler.TruffleCompilable ast) final booleanfinal booleanfinal booleanisSplit()final booleanbooleanabstract booleanisValid()Determines if this call target has valid machine code that can be entered attached to it.abstract booleanDetermines if this call target has valid machine code attached to it, and that this code was compiled in the last tier.final voidfinal booleanfinal booleanneedsCompile(boolean isLastTierCompilation) final booleannodeReplaced(com.oracle.truffle.api.nodes.Node oldNode, com.oracle.truffle.api.nodes.Node newNode, CharSequence reason) final voidonCompilationFailed(Supplier<String> serializedException, boolean silent, boolean bailout, boolean permanentBailout, boolean graphTooBig) final booleanonInvalidate(Object source, CharSequence reason, boolean wasActive) final booleanfinal voidprotected final ObjectprofiledPERoot(Object[] originalArguments) final voidfinal voidprotected static OptimizedTruffleRuntimeruntime()static intscaledThreshold(int callAndLoopThresholdInInterpreter) final booleanfinal StringtoString()final voidfinal booleanMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.oracle.truffle.compiler.TruffleCompilable
getCompilationSpeculationLog
-
Field Details
-
initialized
protected volatile boolean initializedWhether this call target was cloned, compiled or called. -
engine
The engine data associated with this call target. Used to cache option lookups and to gather engine specific statistics. -
speculationLog
protected volatile jdk.vm.ci.meta.SpeculationLog speculationLogThe speculation log to keep track of assumptions taken and failed for previous compilations. -
id
public final long id
-
-
Constructor Details
-
OptimizedCallTarget
protected OptimizedCallTarget(OptimizedCallTarget sourceCallTarget, com.oracle.truffle.api.nodes.RootNode rootNode) -
OptimizedCallTarget
-
-
Method Details
-
highestCompiledTier
public final int highestCompiledTier() -
prepareForCompilation
public final void prepareForCompilation()- Specified by:
prepareForCompilationin interfacecom.oracle.truffle.compiler.TruffleCompilable
-
isTrivial
public boolean isTrivial()- Specified by:
isTrivialin interfacecom.oracle.truffle.compiler.TruffleCompilable
-
dequeueInlined
public final void dequeueInlined()We intentionally do not synchronize here since as it's not worth the sync costs. -
getRootNode
public final com.oracle.truffle.api.nodes.RootNode getRootNode()- Specified by:
getRootNodein interfacecom.oracle.truffle.api.RootCallTarget
-
resetCompilationProfile
public final void resetCompilationProfile() -
call
-
call
-
callIndirect
-
callDirect
In compiled code, this is only used if the callee is not inlined. If the callee is inlined,callInlined(Node, Object...)is used instead, which does not profile arguments, as it is estimated redundant. See the docs ofOptimizedCallTarget. -
callInlined
-
callOSR
-
doInvoke
-
callBoundary
-
scaledThreshold
public static int scaledThreshold(int callAndLoopThresholdInInterpreter) -
shouldCompile
public final boolean shouldCompile() -
wasExecuted
public final boolean wasExecuted() -
profiledPERoot
-
runtime
-
isInitialized
public final boolean isInitialized() -
getOptionValues
public final org.graalvm.options.OptionValues getOptionValues() -
getOptionValue
public final <T> T getOptionValue(org.graalvm.options.OptionKey<T> key) -
compile
public final boolean compile(boolean lastTierCompilation) Returnstrueif the call target was already compiled or was compiled synchronously. Returnsfalseif compilation was not scheduled or is happening in the background. UseisSubmittedForCompilation()to find out whether it is submitted for compilation. -
maybeWaitForTask
-
needsCompile
public final boolean needsCompile(boolean isLastTierCompilation) -
isSubmittedForCompilation
public final boolean isSubmittedForCompilation() -
waitForCompilation
public final void waitForCompilation() -
getCodeAddress
public abstract long getCodeAddress()Gets the address of the machine code for this call target. A non-zero return value denotes the contiguous memory block containing the machine code but does not necessarily represent an entry point for the machine code or even the address of executable instructions. This value is only for informational purposes (e.g., use in a log message). -
isValid
public abstract boolean isValid()Determines if this call target has valid machine code that can be entered attached to it. -
isValidLastTier
public abstract boolean isValidLastTier()Determines if this call target has valid machine code attached to it, and that this code was compiled in the last tier. -
invalidate
Invalidates this call target by invalidating any machine code attached to it.- Parameters:
reason- a textual description of the reason why the machine code was invalidated. May benull.- Returns:
- imprecise: whether code has possibly been invalidated or a compilation has been
cancelled. Returns
falseonly if both are guaranteed to not have happened,trueotherwise.
-
getSpeculationLog
public jdk.vm.ci.meta.SpeculationLog getSpeculationLog()Gets the speculation log used to collect all failed speculations in the compiled code for this call target. Note that this may differ from the speculation log used for compilation. -
asJavaConstant
public final jdk.vm.ci.meta.JavaConstant asJavaConstant()- Specified by:
asJavaConstantin interfacecom.oracle.truffle.compiler.TruffleCompilable
-
isSameOrSplit
public final boolean isSameOrSplit(com.oracle.truffle.compiler.TruffleCompilable ast) - Specified by:
isSameOrSplitin interfacecom.oracle.truffle.compiler.TruffleCompilable
-
cancelCompilation
- Specified by:
cancelCompilationin interfacecom.oracle.truffle.compiler.TruffleCompilable
-
computeBlockCompilations
public final boolean computeBlockCompilations()Computes block compilation usingBlockNodeAPIs. If no block node is used in the AST or block node compilation is disabled then this method always returnsfalse. -
onInvalidate
- Specified by:
onInvalidatein interfacecom.oracle.truffle.compiler.TruffleCompilable
-
onCompilationFailed
-
log
-
getKnownCallSiteCount
public final int getKnownCallSiteCount()- Specified by:
getKnownCallSiteCountin interfacecom.oracle.truffle.compiler.TruffleCompilable
-
getSourceCallTarget
-
getName
- Specified by:
getNamein interfacecom.oracle.truffle.compiler.TruffleCompilable
-
toString
-
createFrame
public static com.oracle.truffle.api.impl.FrameWithoutBoxing createFrame(com.oracle.truffle.api.frame.FrameDescriptor descriptor, Object[] args) Intrinsifiable compiler directive for creating a frame. -
nodeReplaced
public final boolean nodeReplaced(com.oracle.truffle.api.nodes.Node oldNode, com.oracle.truffle.api.nodes.Node newNode, CharSequence reason) - Specified by:
nodeReplacedin interfacecom.oracle.truffle.api.ReplaceObserver
-
accept
public final void accept(com.oracle.truffle.api.nodes.NodeVisitor visitor) -
getNonTrivialNodeCount
public final int getNonTrivialNodeCount()- Specified by:
getNonTrivialNodeCountin interfacecom.oracle.truffle.compiler.TruffleCompilable
-
getCallCount
public final int getCallCount()- Specified by:
getCallCountin interfacecom.oracle.truffle.compiler.TruffleCompilable
-
getCallAndLoopCount
public final int getCallAndLoopCount() -
getInitializedTimestamp
public final long getInitializedTimestamp() -
getDebugProperties
-
countDirectCallNodes
public int countDirectCallNodes()- Specified by:
countDirectCallNodesin interfacecom.oracle.truffle.compiler.TruffleCompilable
-
getInitializedArgumentsProfile
-
getInitializedReturnProfile
-
isSourceCallTarget
public final boolean isSourceCallTarget() -
isSplit
public final boolean isSplit() -
getCallSiteForSplit
-
equals
-
hashCode
-
isSingleCaller
public final boolean isSingleCaller() -
getSingleCallNode
-
resetNeedsSplit
public final void resetNeedsSplit() -
prepareForAOT
public final boolean prepareForAOT() -
engineId
public long engineId()- Specified by:
engineIdin interfacecom.oracle.truffle.compiler.TruffleCompilable
-
getCompilerOptions
-