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 |
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, waitisProfilingEnabled, iterateFrames, notifyTransferToInterpreterformatEvent, getGraalOptions, getRuntimeIfAvailable, getTruffleCompiler, log, logEvent, logEvent, resolveTypeprotected volatile TruffleCompiler truffleCompiler
protected GraalTruffleRuntime.KnownMethods knownMethods
protected void clearState()
public static GraalTruffleRuntime getRuntime()
TruffleRuntime.getRuntime in interface TruffleCompilerRuntimepublic boolean isLatestJVMCI()
public abstract com.oracle.truffle.api.impl.ThreadLocalHandshake getThreadLocalHandshake()
public String getName()
getName in interface com.oracle.truffle.api.TruffleRuntimepublic 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)
TruffleCompilerRuntimeCompilableTruffleAST represented by constant.asCompilableTruffleAST in interface TruffleCompilerRuntimenull if constant does not represent a CompilableTruffleAST or
it cannot be converted to a CompilableTruffleAST in the calling contextpublic JavaConstant getCallTargetForCallNode(JavaConstant callNodeConstant)
TruffleCompilerRuntimecallNode.getCallTargetForCallNode in interface TruffleCompilerRuntimepublic Consumer<OptimizedAssumptionDependency> registerOptimizedAssumptionDependency(JavaConstant optimizedAssumptionConstant)
TruffleCompilerRuntimeConsumer 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 TruffleCompilerRuntimeoptimizedAssumptionConstant - compiler constant representing an OptimizedAssumptionprotected 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)
TruffleCompilerRuntimefield can be constant folded based on Truffle
annotations.getConstantFieldInfo in interface TruffleCompilerRuntimenull if there are no constant folding related Truffle annotations on
fieldpublic TruffleCompilerRuntime.LoopExplosionKind getLoopExplosionKind(ResolvedJavaMethod method)
TruffleCompilerRuntimemethod with constant number of invocations should be unrolled.getLoopExplosionKind in interface TruffleCompilerRuntimepublic ResolvedJavaType resolveType(MetaAccessProvider metaAccess,
String className,
boolean required)
TruffleCompilerRuntimeresolveType in interface TruffleCompilerRuntimeclassName - 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 == falseprotected 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.TruffleRuntimeprotected 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.TruffleRuntimepublic final com.oracle.truffle.api.nodes.IndirectCallNode createIndirectCallNode()
createIndirectCallNode in interface com.oracle.truffle.api.TruffleRuntimepublic final com.oracle.truffle.api.frame.VirtualFrame createVirtualFrame(Object[] arguments, com.oracle.truffle.api.frame.FrameDescriptor frameDescriptor)
createVirtualFrame in interface com.oracle.truffle.api.TruffleRuntimepublic final com.oracle.truffle.api.frame.MaterializedFrame createMaterializedFrame(Object[] arguments)
createMaterializedFrame in interface com.oracle.truffle.api.TruffleRuntimepublic final com.oracle.truffle.api.frame.MaterializedFrame createMaterializedFrame(Object[] arguments, com.oracle.truffle.api.frame.FrameDescriptor frameDescriptor)
createMaterializedFrame in interface com.oracle.truffle.api.TruffleRuntimepublic final com.oracle.truffle.api.Assumption createAssumption()
createAssumption in interface com.oracle.truffle.api.TruffleRuntimepublic final com.oracle.truffle.api.Assumption createAssumption(String name)
createAssumption in interface com.oracle.truffle.api.TruffleRuntimepublic 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.TruffleRuntimepublic final int compilationThresholdScale()
protected abstract StackIntrospection getStackIntrospection()
public <T> T getCapability(Class<T> capability)
getCapability in interface com.oracle.truffle.api.TruffleRuntimepublic 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
ExecutionExceptionTimeoutExceptionpublic 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)
TruffleCompilerRuntimetype is a value type. Reference comparisons (==) between value type
instances have undefined semantics and can either return true or false.isValueType in interface TruffleCompilerRuntimepublic JavaKind getJavaKindForFrameSlotKind(int frameSlotKindTag)
TruffleCompilerRuntimeFrameSlotKind.tag value.getJavaKindForFrameSlotKind in interface TruffleCompilerRuntimepublic int getFrameSlotKindTagForJavaKind(JavaKind kind)
TruffleCompilerRuntimeFrameSlotKind.tag corresponding to a JavaKind value.getFrameSlotKindTagForJavaKind in interface TruffleCompilerRuntimepublic int getFrameSlotKindTagsCount()
TruffleCompilerRuntimeFrameSlotKind.tag values. The valid values are contiguous
from 0 up to but not including the return value.getFrameSlotKindTagsCount in interface TruffleCompilerRuntimepublic TruffleCompilerRuntime.InlineKind getInlineKind(ResolvedJavaMethod original, boolean duringPartialEvaluation)
TruffleCompilerRuntimegetInlineKind in interface TruffleCompilerRuntimeoriginal - candidate for inliningduringPartialEvaluation - whether the inlining context is partial evaluationpublic boolean isInlineable(ResolvedJavaMethod method)
TruffleCompilerRuntimemethod can be inlined by the runtime (independently from Truffle).isInlineable in interface TruffleCompilerRuntimepublic boolean isTruffleBoundary(ResolvedJavaMethod method)
TruffleCompilerRuntimemethod is annotated by TruffleBoundary.isTruffleBoundary in interface TruffleCompilerRuntimepublic boolean isSpecializationMethod(ResolvedJavaMethod method)
TruffleCompilerRuntimemethod is annotated by Specialization.isSpecializationMethod in interface TruffleCompilerRuntimepublic boolean isBytecodeInterpreterSwitch(ResolvedJavaMethod method)
TruffleCompilerRuntimemethod is annotated by BytecodeInterpreterSwitch.isBytecodeInterpreterSwitch in interface TruffleCompilerRuntimepublic boolean isInInterpreter(ResolvedJavaMethod targetMethod)
method is an inInterpeter method.isInInterpreter in interface TruffleCompilerRuntimepublic boolean isTransferToInterpreterMethod(ResolvedJavaMethod method)
method is a method is a transferToInterpreter method.isTransferToInterpreterMethod in interface TruffleCompilerRuntimepublic boolean isBytecodeInterpreterSwitchBoundary(ResolvedJavaMethod method)
TruffleCompilerRuntimemethod is annotated by BytecodeInterpreterSwitchBoundary.isBytecodeInterpreterSwitchBoundary in interface TruffleCompilerRuntimepublic void log(String loggerId, CompilableTruffleAST compilable, String message)
log in interface TruffleCompilerRuntimepublic boolean isSuppressedFailure(CompilableTruffleAST compilable, Supplier<String> serializedException)
TruffleCompilerRuntimeisSuppressedFailure in interface TruffleCompilerRuntimeprotected 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()