public interface TruffleCompilerRuntime
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.| Modifier and Type | Interface and Description |
|---|---|
static class |
TruffleCompilerRuntime.ConstantFieldInfo
Value returned by
TruffleCompilerRuntime.getConstantFieldInfo(ResolvedJavaField)
describing how a field read can be constant folded based on Truffle annotations. |
static class |
TruffleCompilerRuntime.InlineKind |
static class |
TruffleCompilerRuntime.LoopExplosionKind
Controls behavior of
ExplodeLoop annotation. |
| Modifier and Type | Method and Description |
|---|---|
CompilableTruffleAST |
asCompilableTruffleAST(JavaConstant constant)
Gets the
CompilableTruffleAST represented by constant. |
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.
|
JavaConstant |
getCallTargetForCallNode(JavaConstant callNode)
Gets the compiler constant representing the target of
callNode. |
TruffleCompilerRuntime.ConstantFieldInfo |
getConstantFieldInfo(ResolvedJavaField field)
Gets an object describing how a read of
field can be constant folded based on Truffle
annotations. |
int |
getFrameSlotKindTagForJavaKind(JavaKind kind)
Gets the
FrameSlotKind.tag corresponding to a JavaKind value. |
int |
getFrameSlotKindTagsCount()
Gets the number of valid
FrameSlotKind.tag values. |
default <T> T |
getGraalOptions(Class<T> type)
Gets the Graal option values for this runtime in an instance of
type. |
TruffleCompilerRuntime.InlineKind |
getInlineKind(ResolvedJavaMethod original,
boolean duringPartialEvaluation)
Gets an object describing whether and how a method can be inlined based on Truffle
directives.
|
JavaKind |
getJavaKindForFrameSlotKind(int frameSlotKindTag)
Gets the Java kind corresponding to a
FrameSlotKind.tag value. |
TruffleCompilerRuntime.LoopExplosionKind |
getLoopExplosionKind(ResolvedJavaMethod method)
Queries how loops in
method with constant number of invocations should be unrolled. |
static TruffleCompilerRuntime |
getRuntime()
Gets the singleton runtime instance.
|
static TruffleCompilerRuntime |
getRuntimeIfAvailable()
Gets the singleton runtime instance if it is available other returns
null. |
TruffleCompiler |
getTruffleCompiler(CompilableTruffleAST compilable)
Gets the primary
TruffleCompiler instance associated with this runtime, creating and
initializing it in a thread-safe manner first if necessary. |
boolean |
isBytecodeInterpreterSwitch(ResolvedJavaMethod method)
Determines if
method is annotated by BytecodeInterpreterSwitch. |
boolean |
isBytecodeInterpreterSwitchBoundary(ResolvedJavaMethod method)
Determines if
method is annotated by BytecodeInterpreterSwitchBoundary. |
boolean |
isInInterpreter(ResolvedJavaMethod targetMethod)
Determines if
method is the inInterpeter method from CompilerDirectives. |
boolean |
isInlineable(ResolvedJavaMethod method)
Determines if
method can be inlined by the runtime (independently from Truffle). |
boolean |
isSpecializationMethod(ResolvedJavaMethod method)
Determines if
method is annotated by Specialization. |
boolean |
isSuppressedFailure(CompilableTruffleAST compilable,
Supplier<String> serializedException)
Determines if the exception which happened during the compilation is suppressed and should be
silent.
|
boolean |
isTransferToInterpreterMethod(ResolvedJavaMethod method)
Determines if
method is a method is a transferToInterpreter method from
CompilerDirectives. |
boolean |
isTruffleBoundary(ResolvedJavaMethod method)
Determines if
method is annotated by TruffleBoundary. |
boolean |
isValueType(ResolvedJavaType type)
Determines if
type is a value type. |
default void |
log(CompilableTruffleAST compilable,
String message)
Writes
message followed by a new line to the Truffle logger. |
void |
log(String loggerId,
CompilableTruffleAST compilable,
String message) |
default void |
logEvent(CompilableTruffleAST compilable,
int depth,
String event,
Map<String,Object> properties)
Formats a Truffle event
and writes it to the log output.
|
default void |
logEvent(CompilableTruffleAST compilable,
int depth,
String event,
String subject,
Map<String,Object> properties,
String message)
Formats a Truffle event
and writes it to the log output.
|
Consumer<OptimizedAssumptionDependency> |
registerOptimizedAssumptionDependency(JavaConstant optimizedAssumption)
Registers some dependent code on an assumption.
|
default ResolvedJavaType |
resolveType(MetaAccessProvider metaAccess,
String className)
Looks up a type in this runtime.
|
ResolvedJavaType |
resolveType(MetaAccessProvider metaAccess,
String className,
boolean required)
Looks up a type in this runtime.
|
static TruffleCompilerRuntime getRuntimeIfAvailable()
null.static TruffleCompilerRuntime getRuntime()
IllegalStateException - if the singleton instance has not been initializedTruffleCompilerRuntime.ConstantFieldInfo getConstantFieldInfo(ResolvedJavaField field)
field can be constant folded based on Truffle
annotations.null if there are no constant folding related Truffle annotations on
fieldTruffleCompilerRuntime.LoopExplosionKind getLoopExplosionKind(ResolvedJavaMethod method)
method with constant number of invocations should be unrolled.TruffleCompiler getTruffleCompiler(CompilableTruffleAST compilable)
TruffleCompiler instance associated with this runtime, creating and
initializing it in a thread-safe manner first if necessary.CompilableTruffleAST asCompilableTruffleAST(JavaConstant constant)
CompilableTruffleAST represented by constant.null if constant does not represent a CompilableTruffleAST or
it cannot be converted to a CompilableTruffleAST in the calling contextJavaConstant getCallTargetForCallNode(JavaConstant callNode)
callNode.Consumer<OptimizedAssumptionDependency> registerOptimizedAssumptionDependency(JavaConstant optimizedAssumption)
Consumer is 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 a
null argument.
If the assumption is already invalid, then null is returned in which case the caller
(e.g., the compiler) must ensure the dependent code is never executed.optimizedAssumption - compiler constant representing an OptimizedAssumptiondefault void logEvent(CompilableTruffleAST compilable, int depth, String event, Map<String,Object> properties)
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 eventdefault void logEvent(CompilableTruffleAST compilable, int depth, String event, String subject, Map<String,Object> properties, String message)
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 eventdefault void log(CompilableTruffleAST compilable, String message)
message followed by a new line to the Truffle logger.compilable - the currently compiled ASTmessage - message to logvoid log(String loggerId, CompilableTruffleAST compilable, String message)
default String formatEvent(int depth, String event, int eventWidth, String subject, int subjectWidth, Map<String,Object> properties, int propertyWidth)
opt queued :anonymous|ASTSize 20/ 20 |Calls/Thres 7723/ 3 |CallsAndLoop/Thres 7723/ 1000 |Inval# 0
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 propertydefault ResolvedJavaType resolveType(MetaAccessProvider metaAccess,
String className)
className - name of the type to lookup (same format as Class.forName(String)NoClassDefFoundError - if resolution failsResolvedJavaType resolveType(MetaAccessProvider metaAccess,
String className,
boolean required)
className - name of the type to lookup (same format as Class.forName(String)required - specifies if NoClassDefFoundError should be thrown or null
should be returned if resolution failsnull if resolution fails and required == falseNoClassDefFoundError - if resolution fails and required == truedefault <T> T getGraalOptions(Class<T> type)
type.IllegalArgumentException - if this runtime does not support typeTruffleCompilerRuntime.InlineKind getInlineKind(ResolvedJavaMethod original, boolean duringPartialEvaluation)
original - candidate for inliningduringPartialEvaluation - whether the inlining context is partial evaluationboolean isValueType(ResolvedJavaType type)
type is a value type. Reference comparisons (==) between value type
instances have undefined semantics and can either return true or false.JavaKind getJavaKindForFrameSlotKind(int frameSlotKindTag)
FrameSlotKind.tag value.int getFrameSlotKindTagForJavaKind(JavaKind kind)
FrameSlotKind.tag corresponding to a JavaKind value.int getFrameSlotKindTagsCount()
FrameSlotKind.tag values. The valid values are contiguous
from 0 up to but not including the return value.boolean isInlineable(ResolvedJavaMethod method)
method can be inlined by the runtime (independently from Truffle).boolean isTruffleBoundary(ResolvedJavaMethod method)
method is annotated by TruffleBoundary.boolean isSpecializationMethod(ResolvedJavaMethod method)
method is annotated by Specialization.boolean isBytecodeInterpreterSwitch(ResolvedJavaMethod method)
method is annotated by BytecodeInterpreterSwitch.boolean isBytecodeInterpreterSwitchBoundary(ResolvedJavaMethod method)
method is annotated by BytecodeInterpreterSwitchBoundary.boolean isSuppressedFailure(CompilableTruffleAST compilable, Supplier<String> serializedException)
boolean isInInterpreter(ResolvedJavaMethod targetMethod)
method is the inInterpeter method from CompilerDirectives.boolean isTransferToInterpreterMethod(ResolvedJavaMethod method)
method is a method is a transferToInterpreter method from
CompilerDirectives.