Interface TruffleCompilable
public interface TruffleCompilable
A Truffle AST that can be compiled by a
TruffleCompiler.-
Method Summary
Modifier and TypeMethodDescriptionjdk.vm.ci.meta.JavaConstantGets this AST as a compiler constant.booleancancelCompilation(CharSequence reason) Cancel the compilation of this truffle ast.intReturns the number of direct calls of a call target.longengineId()Returns a process-unique id for the underlying engine.intReturn the total number of calls to this target.jdk.vm.ci.meta.SpeculationLogGets a speculation log to be used for a single Truffle compilation.Returns a set of compiler options that where specified by the user.intgetName()Gets a descriptive name for this call target.intReturns the estimate of the Truffle node count in this AST.default intReturns the number of successful compilations of this compilable.booleanbooleanvoidonCompilationFailed(Supplier<String> serializedException, boolean suppressed, boolean bailout, boolean permanentBailout, boolean graphTooBig) Notifies this object that a compilation of the AST it represents failed.default voidonCompilationSuccess(int compilationTier, boolean lastTier) Called after a successful compilation of a call target.booleanonInvalidate(Object source, CharSequence reason, boolean wasActive) Invoked when installed code associated with this AST was invalidated due to assumption invalidation.default voidDeprecated.default booleanprepareForCompilation(boolean rootCompilation, int compilationTier, boolean lastTier) Called before call target is used for runtime compilation, either as root compilation or via inlining.static StringReturnseserialized as a string.
-
Method Details
-
asJavaConstant
jdk.vm.ci.meta.JavaConstant asJavaConstant()Gets this AST as a compiler constant. -
getCompilationSpeculationLog
jdk.vm.ci.meta.SpeculationLog getCompilationSpeculationLog()Gets a speculation log to be used for a single Truffle compilation. The returned speculation log provides access to all relevant failed speculations as well as support for making speculation during a single compilation. -
onCompilationFailed
void onCompilationFailed(Supplier<String> serializedException, boolean suppressed, boolean bailout, boolean permanentBailout, boolean graphTooBig) Notifies this object that a compilation of the AST it represents failed.- Parameters:
serializedException- serializedException a serialized representation of the exception representing the reason for compilation failure. SeeserializeException(Throwable).suppressed- specifies whether the failure was suppressed and should be silent. Use theTruffleCompilerRuntime.isSuppressedFailure(TruffleCompilable, Supplier)to determine if the failure should be suppressed.bailout- specifies whether the failure was a bailout or an error in the compiler. A bailout means the compiler aborted the compilation based on some of property of the AST (e.g., too big). A non-bailout means an unexpected error in the compiler itself.permanentBailout- specifies if a bailout is due to a condition that probably won't change if this AST is compiled again. This value is meaningless ifbailout == false.graphTooBig- graph was too big
-
onCompilationSuccess
default void onCompilationSuccess(int compilationTier, boolean lastTier) Called after a successful compilation of a call target.- Parameters:
compilationTier- which tier this compilation is compiled withlastTier-trueif there is no next compilation tier (no next tier exists, or it is disabled)
-
onInvalidate
Invoked when installed code associated with this AST was invalidated due to assumption invalidation. This method is not invoked across isolation boundaries, so can throw an error in such a case. Note that this method may be invoked multiple times, if multiple installed codes were active for this AST. -
getName
String getName()Gets a descriptive name for this call target. -
getNonTrivialNodeCount
int getNonTrivialNodeCount()Returns the estimate of the Truffle node count in this AST. -
countDirectCallNodes
int countDirectCallNodes()Returns the number of direct calls of a call target. This may be used by an inlining heuristic to inform exploration. -
getCallCount
int getCallCount()Return the total number of calls to this target. -
cancelCompilation
Cancel the compilation of this truffle ast. -
isSameOrSplit
- Parameters:
ast- the ast to compare to- Returns:
- true if this ast and the argument are the same, one is a split of the other or they are both splits of the same ast. False otherwise.
-
getKnownCallSiteCount
int getKnownCallSiteCount()- Returns:
- How many direct callers is this ast known to have.
-
prepareForCompilation
Deprecated.useprepareForCompilation(boolean, int, boolean)instead.Called before call target is used for runtime compilation, either as root compilation or via inlining. -
prepareForCompilation
default boolean prepareForCompilation(boolean rootCompilation, int compilationTier, boolean lastTier) Called before call target is used for runtime compilation, either as root compilation or via inlining.- Parameters:
rootCompilation- whether this compilation is compiled as root methodcompilationTier- which tier this compilation is compiled withlastTier-trueif there is no next compilation tier (no next tier exists, or it is disabled).
-
serializeException
Returnseserialized as a string. The format of the returned string is:(class_name ":")+ "\n" stack_trace
where the first
class_nameise.getClass().getName()and every subsequentclass_nameis the super class of the previous one up to but not includingThrowable. For example:"java.lang.NullPointerException:java.lang.RuntimeException:java.lang.Exception:\n" + "java.lang.NullPointerException: compiler error\n\tat MyClass.mash(MyClass.java:9)\n\tat MyClass.main(MyClass.java:6)" -
isTrivial
boolean isTrivial()- Returns:
trueis the root nodes of this AST trivial,falseotherwise.
-
engineId
long engineId()Returns a process-unique id for the underlying engine. This may be used to cache thecompiler optionsas they are guaranteed to be the same per engine. -
getCompilerOptions
-
getSuccessfulCompilationCount
default int getSuccessfulCompilationCount()Returns the number of successful compilations of this compilable. All compilation tiers are counted together.
-
prepareForCompilation(boolean, int, boolean)instead.