public abstract class GraalTruffleRuntime extends Object implements com.oracle.truffle.api.TruffleRuntime, TruffleCompilerRuntime
Modifier and Type | Class and Description |
---|---|
class |
GraalTruffleRuntime.KnownMethods |
static class |
GraalTruffleRuntime.StackTraceHelper |
TruffleCompilerRuntime.ConstantFieldInfo, TruffleCompilerRuntime.InlineKind, TruffleCompilerRuntime.LoopExplosionKind
Modifier and Type | Field and Description |
---|---|
protected GraalTruffleRuntime.KnownMethods |
knownMethods |
protected TruffleCompiler |
truffleCompiler |
Constructor and Description |
---|
GraalTruffleRuntime(Iterable<Class<?>> extraLookupTypes) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(GraalTruffleRuntimeListener listener) |
CompilableTruffleAST |
asCompilableTruffleAST(JavaConstant constant)
Gets the
CompilableTruffleAST represented by constant . |
protected abstract <T> T |
asObject(Class<T> type,
JavaConstant constant) |
void |
bypassedInstalledCode(OptimizedCallTarget target)
Notifies this runtime when a Truffle AST is being executed in the Truffle interpreter even
though compiled code is available for the AST.
|
protected void |
clearState()
Used only to reset state for native image compilation.
|
int |
compilationThresholdScale() |
com.oracle.truffle.api.Assumption |
createAssumption() |
com.oracle.truffle.api.Assumption |
createAssumption(String name) |
com.oracle.truffle.api.nodes.DirectCallNode |
createDirectCallNode(com.oracle.truffle.api.CallTarget target) |
com.oracle.truffle.api.nodes.IndirectCallNode |
createIndirectCallNode() |
com.oracle.truffle.api.nodes.LoopNode |
createLoopNode(com.oracle.truffle.api.nodes.RepeatingNode repeatingNode) |
com.oracle.truffle.api.frame.MaterializedFrame |
createMaterializedFrame(Object[] arguments) |
com.oracle.truffle.api.frame.MaterializedFrame |
createMaterializedFrame(Object[] arguments,
com.oracle.truffle.api.frame.FrameDescriptor frameDescriptor) |
protected abstract OptimizedCallTarget |
createOptimizedCallTarget(OptimizedCallTarget source,
com.oracle.truffle.api.nodes.RootNode rootNode) |
abstract SpeculationLog |
createSpeculationLog() |
com.oracle.truffle.api.frame.VirtualFrame |
createVirtualFrame(Object[] arguments,
com.oracle.truffle.api.frame.FrameDescriptor frameDescriptor) |
protected void |
doCompile(OptimizedCallTarget callTarget,
TruffleCompilationTask task) |
protected void |
doCompile(TruffleDebugContext debug,
OptimizedCallTarget callTarget,
TruffleCompilationTask task) |
void |
finishCompilation(OptimizedCallTarget optimizedCallTarget,
CompilationTask task,
boolean mayBeAsynchronous) |
protected abstract JavaConstant |
forObject(Object object) |
protected int |
getArrayBaseOffset(Class<?> componentType) |
protected int |
getArrayIndexScale(Class<?> componentType) |
protected int |
getBaseInstanceSize(Class<?> type) |
JavaConstant |
getCallTargetForCallNode(JavaConstant callNodeConstant)
Gets the compiler constant representing the target of
callNode . |
<T> T |
getCapability(Class<T> capability) |
int |
getCompilationQueueSize() |
abstract BackgroundCompileQueue |
getCompileQueue() |
protected abstract String |
getCompilerConfigurationName()
This method allows retrieval of the compiler configuration without requiring to initialize
the
TruffleCompiler with
getTruffleCompiler . |
protected long |
getCompilerIdleDelay(OptimizedCallTarget callTarget)
Gets the time in milliseconds an idle compiler thread will wait for new tasks before
terminating.
|
TruffleCompilerRuntime.ConstantFieldInfo |
getConstantFieldInfo(ResolvedJavaField field)
Gets an object describing how a read of
field can be constant folded based on Truffle
annotations. |
EngineCacheSupport |
getEngineCacheSupport() |
protected static EngineData |
getEngineData(com.oracle.truffle.api.nodes.RootNode rootNode)
Use
OptimizedCallTarget.engine whenever possible as it's much faster. |
protected abstract com.oracle.truffle.api.impl.AbstractFastThreadLocal |
getFastThreadLocalImpl() |
protected Object |
getFieldValue(ResolvedJavaField resolvedJavaField,
Object obj) |
boolean |
getFrameMaterializeCalled(com.oracle.truffle.api.frame.FrameDescriptor descriptor)
Accessor for non-public state in
FrameDescriptor . |
int |
getFrameSlotKindTagForJavaKind(JavaKind kind)
Gets the
FrameSlotKind.tag corresponding to a JavaKind value. |
int |
getFrameSlotKindTagsCount()
Gets the number of valid
FrameSlotKind.tag values. |
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. |
GraalTruffleRuntime.KnownMethods |
getKnownMethods() |
GraalTruffleRuntimeListener |
getListener() |
Iterable<Class<?>> |
getLookupTypes()
Returns a set of classes that need to be initialized before compilations can be performed.
|
TruffleCompilerRuntime.LoopExplosionKind |
getLoopExplosionKind(ResolvedJavaMethod method)
Queries how loops in
method with constant number of invocations should be unrolled. |
protected LoopNodeFactory |
getLoopNodeFactory() |
String |
getName() |
protected int |
getObjectAlignment() |
static Map<String,Object> |
getOptionsForCompiler(OptimizedCallTarget target)
Returns OptimizedCallTarget's
PolyglotCompilerOptions as a Map . |
protected Object[] |
getResolvedFields(Class<?> type,
boolean includePrimitive,
boolean includeSuperclasses) |
static GraalTruffleRuntime |
getRuntime()
Utility method that casts the singleton
TruffleRuntime . |
protected abstract StackIntrospection |
getStackIntrospection() |
long |
getStackOverflowLimit() |
protected com.oracle.truffle.api.impl.TVMCI.Test<?,?> |
getTestTvmci() |
abstract com.oracle.truffle.api.impl.ThreadLocalHandshake |
getThreadLocalHandshake() |
protected GraalTVMCI |
getTvmci() |
void |
initializeKnownMethods(MetaAccessProvider metaAccess) |
protected void |
installDefaultListeners() |
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 an inInterpeter method. |
boolean |
isInlineable(ResolvedJavaMethod method)
Determines if
method can be inlined by the runtime (independently from Truffle). |
boolean |
isInliningCutoff(ResolvedJavaMethod method)
Determines if
method is annotated by InliningCutoff . |
boolean |
isLatestJVMCI() |
protected abstract boolean |
isPrintGraphEnabled() |
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.
|
protected boolean |
isSuppressedTruffleRuntimeException(Throwable throwable)
Allows
GraalTruffleRuntime subclasses to suppress exceptions such as an exception
thrown during VM exit. |
boolean |
isTransferToInterpreterMethod(ResolvedJavaMethod method)
Determines if
method is a method is a transferToInterpreter method. |
boolean |
isTruffleBoundary(ResolvedJavaMethod method)
Determines if
method is annotated by TruffleBoundary . |
boolean |
isValueType(ResolvedJavaType type)
Determines if
type is a value type. |
<T> T |
iterateFrames(com.oracle.truffle.api.frame.FrameInstanceVisitor<T> visitor,
int skipFrames) |
void |
log(String loggerId,
CompilableTruffleAST compilable,
String message) |
void |
markFrameMaterializeCalled(com.oracle.truffle.api.frame.FrameDescriptor descriptor)
Accessor for non-public state in
FrameDescriptor . |
abstract TruffleCompiler |
newTruffleCompiler() |
protected AutoCloseable |
openCompilerThreadScope()
Gets a closeable that will be used in a try-with-resources statement surrounding the run-loop
of a Truffle compiler thread.
|
protected String |
printStackTraceToString(Throwable e) |
Consumer<OptimizedAssumptionDependency> |
registerOptimizedAssumptionDependency(JavaConstant optimizedAssumptionConstant)
Registers some dependent code on an assumption.
|
void |
removeListener(GraalTruffleRuntimeListener listener) |
ResolvedJavaType |
resolveType(MetaAccessProvider metaAccess,
String className,
boolean required)
Looks up a type in this runtime.
|
protected static ResolvedJavaMethod |
searchMethod(ResolvedJavaType type,
String name) |
CompilationTask |
submitForCompilation(OptimizedCallTarget optimizedCallTarget,
boolean lastTierCompilation) |
void |
waitForCompilation(OptimizedCallTarget optimizedCallTarget,
long timeout) |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isProfilingEnabled, iterateFrames, notifyTransferToInterpreter
formatEvent, getGraalOptions, getRuntimeIfAvailable, getTruffleCompiler, log, logEvent, logEvent, resolveType
protected volatile TruffleCompiler truffleCompiler
protected GraalTruffleRuntime.KnownMethods knownMethods
protected void clearState()
public static GraalTruffleRuntime getRuntime()
TruffleRuntime
.getRuntime
in interface TruffleCompilerRuntime
public boolean isLatestJVMCI()
public abstract com.oracle.truffle.api.impl.ThreadLocalHandshake getThreadLocalHandshake()
public String getName()
getName
in interface com.oracle.truffle.api.TruffleRuntime
public final Iterable<Class<?>> getLookupTypes()
protected abstract String getCompilerConfigurationName()
TruffleCompiler
with
getTruffleCompiler
. The result of this method should always match
TruffleCompiler.getCompilerConfigurationName()
.protected GraalTVMCI getTvmci()
protected com.oracle.truffle.api.impl.TVMCI.Test<?,?> getTestTvmci()
public CompilableTruffleAST asCompilableTruffleAST(JavaConstant constant)
TruffleCompilerRuntime
CompilableTruffleAST
represented by constant
.asCompilableTruffleAST
in interface TruffleCompilerRuntime
null
if constant
does not represent a CompilableTruffleAST
or
it cannot be converted to a CompilableTruffleAST
in the calling contextpublic JavaConstant getCallTargetForCallNode(JavaConstant callNodeConstant)
TruffleCompilerRuntime
callNode
.getCallTargetForCallNode
in interface TruffleCompilerRuntime
public Consumer<OptimizedAssumptionDependency> registerOptimizedAssumptionDependency(JavaConstant optimizedAssumptionConstant)
TruffleCompilerRuntime
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.registerOptimizedAssumptionDependency
in interface TruffleCompilerRuntime
optimizedAssumptionConstant
- compiler constant representing an OptimizedAssumption
protected abstract JavaConstant forObject(Object object)
protected abstract <T> T asObject(Class<T> type, JavaConstant constant)
protected abstract boolean isPrintGraphEnabled()
public abstract TruffleCompiler newTruffleCompiler()
public TruffleCompilerRuntime.ConstantFieldInfo getConstantFieldInfo(ResolvedJavaField field)
TruffleCompilerRuntime
field
can be constant folded based on Truffle
annotations.getConstantFieldInfo
in interface TruffleCompilerRuntime
null
if there are no constant folding related Truffle annotations on
field
public TruffleCompilerRuntime.LoopExplosionKind getLoopExplosionKind(ResolvedJavaMethod method)
TruffleCompilerRuntime
method
with constant number of invocations should be unrolled.getLoopExplosionKind
in interface TruffleCompilerRuntime
public ResolvedJavaType resolveType(MetaAccessProvider metaAccess, String className, boolean required)
TruffleCompilerRuntime
resolveType
in interface TruffleCompilerRuntime
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 == false
protected void installDefaultListeners()
public final void initializeKnownMethods(MetaAccessProvider metaAccess)
public void markFrameMaterializeCalled(com.oracle.truffle.api.frame.FrameDescriptor descriptor)
FrameDescriptor
.public boolean getFrameMaterializeCalled(com.oracle.truffle.api.frame.FrameDescriptor descriptor)
FrameDescriptor
.public com.oracle.truffle.api.nodes.LoopNode createLoopNode(com.oracle.truffle.api.nodes.RepeatingNode repeatingNode)
createLoopNode
in interface com.oracle.truffle.api.TruffleRuntime
protected final LoopNodeFactory getLoopNodeFactory()
public final EngineCacheSupport getEngineCacheSupport()
public final com.oracle.truffle.api.nodes.DirectCallNode createDirectCallNode(com.oracle.truffle.api.CallTarget target)
createDirectCallNode
in interface com.oracle.truffle.api.TruffleRuntime
public final com.oracle.truffle.api.nodes.IndirectCallNode createIndirectCallNode()
createIndirectCallNode
in interface com.oracle.truffle.api.TruffleRuntime
public final com.oracle.truffle.api.frame.VirtualFrame createVirtualFrame(Object[] arguments, com.oracle.truffle.api.frame.FrameDescriptor frameDescriptor)
createVirtualFrame
in interface com.oracle.truffle.api.TruffleRuntime
public final com.oracle.truffle.api.frame.MaterializedFrame createMaterializedFrame(Object[] arguments)
createMaterializedFrame
in interface com.oracle.truffle.api.TruffleRuntime
public final com.oracle.truffle.api.frame.MaterializedFrame createMaterializedFrame(Object[] arguments, com.oracle.truffle.api.frame.FrameDescriptor frameDescriptor)
createMaterializedFrame
in interface com.oracle.truffle.api.TruffleRuntime
public final com.oracle.truffle.api.Assumption createAssumption()
createAssumption
in interface com.oracle.truffle.api.TruffleRuntime
public final com.oracle.truffle.api.Assumption createAssumption(String name)
createAssumption
in interface com.oracle.truffle.api.TruffleRuntime
public final GraalTruffleRuntimeListener getListener()
public final <T> T iterateFrames(com.oracle.truffle.api.frame.FrameInstanceVisitor<T> visitor, int skipFrames)
iterateFrames
in interface com.oracle.truffle.api.TruffleRuntime
public final int compilationThresholdScale()
protected abstract StackIntrospection getStackIntrospection()
public <T> T getCapability(Class<T> capability)
getCapability
in interface com.oracle.truffle.api.TruffleRuntime
public abstract SpeculationLog createSpeculationLog()
protected abstract OptimizedCallTarget createOptimizedCallTarget(OptimizedCallTarget source, com.oracle.truffle.api.nodes.RootNode rootNode)
public void addListener(GraalTruffleRuntimeListener listener)
public void removeListener(GraalTruffleRuntimeListener listener)
protected final void doCompile(OptimizedCallTarget callTarget, TruffleCompilationTask task)
protected final void doCompile(TruffleDebugContext debug, OptimizedCallTarget callTarget, TruffleCompilationTask task)
public abstract BackgroundCompileQueue getCompileQueue()
public CompilationTask submitForCompilation(OptimizedCallTarget optimizedCallTarget, boolean lastTierCompilation)
public void finishCompilation(OptimizedCallTarget optimizedCallTarget, CompilationTask task, boolean mayBeAsynchronous)
public void waitForCompilation(OptimizedCallTarget optimizedCallTarget, long timeout) throws ExecutionException, TimeoutException
ExecutionException
TimeoutException
public int getCompilationQueueSize()
public void bypassedInstalledCode(OptimizedCallTarget target)
public GraalTruffleRuntime.KnownMethods getKnownMethods()
protected static EngineData getEngineData(com.oracle.truffle.api.nodes.RootNode rootNode)
OptimizedCallTarget.engine
whenever possible as it's much faster.protected static ResolvedJavaMethod searchMethod(ResolvedJavaType type, String name)
public boolean isValueType(ResolvedJavaType type)
TruffleCompilerRuntime
type
is a value type. Reference comparisons (==) between value type
instances have undefined semantics and can either return true or false.isValueType
in interface TruffleCompilerRuntime
public JavaKind getJavaKindForFrameSlotKind(int frameSlotKindTag)
TruffleCompilerRuntime
FrameSlotKind.tag
value.getJavaKindForFrameSlotKind
in interface TruffleCompilerRuntime
public int getFrameSlotKindTagForJavaKind(JavaKind kind)
TruffleCompilerRuntime
FrameSlotKind.tag
corresponding to a JavaKind
value.getFrameSlotKindTagForJavaKind
in interface TruffleCompilerRuntime
public int getFrameSlotKindTagsCount()
TruffleCompilerRuntime
FrameSlotKind.tag
values. The valid values are contiguous
from 0 up to but not including the return value.getFrameSlotKindTagsCount
in interface TruffleCompilerRuntime
public TruffleCompilerRuntime.InlineKind getInlineKind(ResolvedJavaMethod original, boolean duringPartialEvaluation)
TruffleCompilerRuntime
getInlineKind
in interface TruffleCompilerRuntime
original
- candidate for inliningduringPartialEvaluation
- whether the inlining context is partial evaluationpublic boolean isInlineable(ResolvedJavaMethod method)
TruffleCompilerRuntime
method
can be inlined by the runtime (independently from Truffle).isInlineable
in interface TruffleCompilerRuntime
public boolean isTruffleBoundary(ResolvedJavaMethod method)
TruffleCompilerRuntime
method
is annotated by TruffleBoundary
.isTruffleBoundary
in interface TruffleCompilerRuntime
public boolean isSpecializationMethod(ResolvedJavaMethod method)
TruffleCompilerRuntime
method
is annotated by Specialization
.isSpecializationMethod
in interface TruffleCompilerRuntime
public boolean isBytecodeInterpreterSwitch(ResolvedJavaMethod method)
TruffleCompilerRuntime
method
is annotated by BytecodeInterpreterSwitch
.isBytecodeInterpreterSwitch
in interface TruffleCompilerRuntime
public boolean isInliningCutoff(ResolvedJavaMethod method)
TruffleCompilerRuntime
method
is annotated by InliningCutoff
.isInliningCutoff
in interface TruffleCompilerRuntime
public boolean isInInterpreter(ResolvedJavaMethod targetMethod)
method
is an inInterpeter method.isInInterpreter
in interface TruffleCompilerRuntime
public boolean isTransferToInterpreterMethod(ResolvedJavaMethod method)
method
is a method is a transferToInterpreter method.isTransferToInterpreterMethod
in interface TruffleCompilerRuntime
public boolean isBytecodeInterpreterSwitchBoundary(ResolvedJavaMethod method)
TruffleCompilerRuntime
method
is annotated by BytecodeInterpreterSwitchBoundary
.isBytecodeInterpreterSwitchBoundary
in interface TruffleCompilerRuntime
public void log(String loggerId, CompilableTruffleAST compilable, String message)
log
in interface TruffleCompilerRuntime
public boolean isSuppressedFailure(CompilableTruffleAST compilable, Supplier<String> serializedException)
TruffleCompilerRuntime
isSuppressedFailure
in interface TruffleCompilerRuntime
protected boolean isSuppressedTruffleRuntimeException(Throwable throwable)
GraalTruffleRuntime
subclasses to suppress exceptions such as an exception
thrown during VM exit. Unlike GraalTruffleRuntime.isSuppressedFailure(CompilableTruffleAST, Supplier)
this method is called only for exceptions thrown on the Truffle runtime side, so it does not
need to stringify the passed exception.protected AutoCloseable openCompilerThreadScope()
GraalTruffleRuntime.getCompilerIdleDelay(OptimizedCallTarget)
, this can be used to release resources
held by idle Truffle compiler threads.
If a non-null value is returned, its AutoCloseable.close()
must not throw an
exception.protected long getCompilerIdleDelay(OptimizedCallTarget callTarget)
<= 0
means that compiler threads block indefinitely waiting
for a task and thus never terminate.public static Map<String,Object> getOptionsForCompiler(OptimizedCallTarget target)
PolyglotCompilerOptions
as a Map
. The returned
map can be passed as a options
to the TruffleCompiler
methods.protected int getObjectAlignment()
protected int getArrayBaseOffset(Class<?> componentType)
protected int getArrayIndexScale(Class<?> componentType)
protected int getBaseInstanceSize(Class<?> type)
protected Object[] getResolvedFields(Class<?> type, boolean includePrimitive, boolean includeSuperclasses)
protected abstract com.oracle.truffle.api.impl.AbstractFastThreadLocal getFastThreadLocalImpl()
public long getStackOverflowLimit()