Interface TruffleCompilerRuntime
public interface TruffleCompilerRuntime
Defines an interface to the Truffle metadata required by a
TruffleCompiler without
exposing a Truffle compiler directly to Truffle AST classes. This allows a Truffle runtime and
Truffle compiler to exists in separate heaps or even separate processes.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumstatic enumControls behavior ofExplodeLoopannotation. -
Method Summary
Modifier and TypeMethodDescriptionasCompilableTruffleAST(jdk.vm.ci.meta.JavaConstant constant) Gets theTruffleCompilablerepresented byconstant.default StringformatEvent(int depth, String event, int eventWidth, String subject, int subjectWidth, Map<String, Object> properties, int propertyWidth) Formats a message describing a Truffle event as a single line of text.getConstantFieldInfo(jdk.vm.ci.meta.ResolvedJavaField field) Gets an object describing how a read offieldcan be constant folded based on Truffle annotations.getHostMethodInfo(jdk.vm.ci.meta.ResolvedJavaMethod method) Returns Truffle related method information during host compilation.getPartialEvaluationMethodInfo(jdk.vm.ci.meta.ResolvedJavaMethod method) Returns Truffle related method information during host compilation.booleanisSuppressedFailure(TruffleCompilable compilable, Supplier<String> serializedException) Determines if the exception which happened during the compilation is suppressed and should be silent.booleanisValueType(jdk.vm.ci.meta.ResolvedJavaType type) Determines iftypeis a value type.default voidlog(TruffleCompilable compilable, String message) Writesmessagefollowed by a new line to the Truffle logger.voidlog(String loggerId, TruffleCompilable compilable, String message) default voidlogEvent(TruffleCompilable compilable, int depth, String event, String subject, Map<String, Object> properties, String message) Formats a Truffle event and writes it to the log output.default voidFormats a Truffle event and writes it to the log output.voidonCodeInstallation(TruffleCompilable compilable, jdk.vm.ci.code.InstalledCode installedCode) Notifies this runtime onceinstalledCodehas been installed in the code cache.registerOptimizedAssumptionDependency(jdk.vm.ci.meta.JavaConstant optimizedAssumption) Registers some dependent code on an assumption.default jdk.vm.ci.meta.ResolvedJavaTyperesolveType(jdk.vm.ci.meta.MetaAccessProvider metaAccess, String className) Looks up a type in this runtime.jdk.vm.ci.meta.ResolvedJavaTyperesolveType(jdk.vm.ci.meta.MetaAccessProvider metaAccess, String className, boolean required) Looks up a type in this runtime.
-
Method Details
-
onCodeInstallation
Notifies this runtime onceinstalledCodehas been installed in the code cache. On SubstrateVM this callback is currently unused.- Parameters:
compilable- thecompilableto install code intoinstalledCode- code that has just been installed in the code cache
-
getPartialEvaluationMethodInfo
PartialEvaluationMethodInfo getPartialEvaluationMethodInfo(jdk.vm.ci.meta.ResolvedJavaMethod method) Returns Truffle related method information during host compilation. Do not call this method directly use PartialEvaluator#getMethodInfo instead. TODO GR-44222 as soon as the annotation API is available in libgraal this can be moved to the compiler implementation side. -
getHostMethodInfo
Returns Truffle related method information during host compilation. Do not call this method directly use TruffleHostEnvironment#getHostMethodInfo instead. TODO GR-44222 as soon as the annotation API is available in libgraal this can be moved to the compiler implementation side.- See Also:
-
getConstantFieldInfo
Gets an object describing how a read offieldcan be constant folded based on Truffle annotations. Do not call this method directly use PartialEvaluator#getConstantFieldInfo instead. TODO GR-44222 as soon as the annotation API is available in libgraal this can be moved to the compiler implementation side.- Returns:
nullif there are no constant folding related Truffle annotations onfield
-
asCompilableTruffleAST
Gets theTruffleCompilablerepresented byconstant.- Returns:
nullifconstantdoes not represent aTruffleCompilableor it cannot be converted to aTruffleCompilablein the calling context
-
registerOptimizedAssumptionDependency
Consumer<OptimizedAssumptionDependency> registerOptimizedAssumptionDependency(jdk.vm.ci.meta.JavaConstant optimizedAssumption) Registers some dependent code on an assumption. As the dependent code may not yet be available, aConsumeris returned that must be notified when the code becomes available. If there is an error while compiling or installing the code, the returned consumer must be called with anullargument. If the assumption is already invalid, thennullis returned in which case the caller (e.g., the compiler) must ensure the dependent code is never executed.- Parameters:
optimizedAssumption- compiler constant representing anOptimizedAssumption
-
logEvent
default void logEvent(TruffleCompilable compilable, int depth, String event, Map<String, Object> properties) Formats a Truffle event and writes it to the log output.- Parameters:
compilable- the currently compiled AST used as a subjectdepth- nesting depth of the eventevent- a short description of the event being tracedproperties- name/value pairs describing properties relevant to the event- Since:
- 20.1.0
-
logEvent
default void logEvent(TruffleCompilable compilable, int depth, String event, String subject, Map<String, Object> properties, String message) Formats a Truffle event and writes it to the log output.- Parameters:
compilable- the currently compiled ASTdepth- nesting depth of the eventevent- a short description of the event being tracedsubject- a description of the event's subjectproperties- name/value pairs describing properties relevant to the eventmessage- optional additional message appended to the formatted event- Since:
- 20.1.0
-
log
Writesmessagefollowed by a new line to the Truffle logger.- Parameters:
compilable- the currently compiled ASTmessage- message to log
-
log
-
formatEvent
default String formatEvent(int depth, String event, int eventWidth, String subject, int subjectWidth, Map<String, Object> properties, int propertyWidth) Formats a message describing a Truffle event as a single line of text. A representative event trace line is shown below:opt queued :anonymous <split-1563da5> |ASTSize 20/ 20 |Calls/Thres 7723/ 3 |CallsAndLoop/Thres 7723/ 1000 |Inval# 0
- Parameters:
depth- nesting depth of the event (subject column is indented @{code depth * 2})event- a short description of the event being traced (e.g., "opt done")eventWidth- the minimum width of the event columnsubject- a description of the event's subject (e.g., name of a Truffle AST)subjectWidth- the minimum width of the subject columnproperties- name/value pairs describing properties relevant to the eventpropertyWidth- the minimum width of the column for each property
-
resolveType
default jdk.vm.ci.meta.ResolvedJavaType resolveType(jdk.vm.ci.meta.MetaAccessProvider metaAccess, String className) Looks up a type in this runtime.- Parameters:
className- name of the type to lookup (same format asClass.forName(String)- Returns:
- the resolved type
- Throws:
NoClassDefFoundError- if resolution fails
-
resolveType
jdk.vm.ci.meta.ResolvedJavaType resolveType(jdk.vm.ci.meta.MetaAccessProvider metaAccess, String className, boolean required) Looks up a type in this runtime.- Parameters:
className- name of the type to lookup (same format asClass.forName(String)required- specifies ifNoClassDefFoundErrorshould be thrown ornullshould be returned if resolution fails- Returns:
- the resolved type or
nullif resolution fails andrequired == false - Throws:
NoClassDefFoundError- if resolution fails andrequired == true
-
isValueType
boolean isValueType(jdk.vm.ci.meta.ResolvedJavaType type) Determines iftypeis a value type. Reference comparisons (==) between value type instances have undefined semantics and can either return true or false. -
isSuppressedFailure
Determines if the exception which happened during the compilation is suppressed and should be silent.
-