Class OptimizedTruffleRuntime

java.lang.Object
com.oracle.truffle.runtime.OptimizedTruffleRuntime
All Implemented Interfaces:
com.oracle.truffle.api.TruffleRuntime, com.oracle.truffle.compiler.TruffleCompilerRuntime
Direct Known Subclasses:
HotSpotTruffleRuntime

public abstract class OptimizedTruffleRuntime extends Object implements com.oracle.truffle.api.TruffleRuntime, com.oracle.truffle.compiler.TruffleCompilerRuntime
Implementation of the Truffle runtime when running on top of Graal. There is only one per VM.
  • Field Details

    • MIN_COMPILER_VERSION

      public static final org.graalvm.home.Version MIN_COMPILER_VERSION
    • MIN_JDK_VERSION

      public static final int MIN_JDK_VERSION
      See Also:
    • MAX_JDK_VERSION

      public static final int MAX_JDK_VERSION
      See Also:
    • NEXT_VERSION_UPDATE

      public static final org.graalvm.home.Version NEXT_VERSION_UPDATE
    • truffleCompiler

      protected volatile com.oracle.truffle.compiler.TruffleCompiler truffleCompiler
    • initializeCallTarget

      protected volatile OptimizedCallTarget initializeCallTarget
    • knownMethods

      protected OptimizedTruffleRuntime.KnownMethods knownMethods
    • engineOptions

      protected volatile org.graalvm.options.OptionDescriptors engineOptions
    • compilationSupport

      protected final com.oracle.truffle.compiler.TruffleCompilationSupport compilationSupport
  • Constructor Details

    • OptimizedTruffleRuntime

      public OptimizedTruffleRuntime(com.oracle.truffle.compiler.TruffleCompilationSupport compilationSupport, Iterable<Class<?>> extraLookupTypes)
  • Method Details

    • clearState

      protected void clearState()
      Used only to reset state for native image compilation.
    • getRuntime

      public static OptimizedTruffleRuntime getRuntime()
      Utility method that casts the singleton TruffleRuntime.
    • initializeEngineCacheSupport

      public final void initializeEngineCacheSupport(EngineCacheSupport support)
    • loadEngineCacheSupport

      protected EngineCacheSupport loadEngineCacheSupport(List<org.graalvm.options.OptionDescriptors> options)
    • getThreadLocalHandshake

      public abstract com.oracle.truffle.api.impl.ThreadLocalHandshake getThreadLocalHandshake()
    • getName

      public String getName()
      Specified by:
      getName in interface com.oracle.truffle.api.TruffleRuntime
    • getLookupTypes

      public final Iterable<Class<?>> getLookupTypes()
      Returns a set of classes that need to be initialized before compilations can be performed.
    • getCompilerConfigurationName

      public final String getCompilerConfigurationName()
      This method allows retrieval of the compiler configuration without requiring to initialize the TruffleCompiler with getTruffleCompiler.
    • getTruffleCompiler

      public abstract com.oracle.truffle.compiler.TruffleCompiler getTruffleCompiler(com.oracle.truffle.compiler.TruffleCompilable compilable)
    • listCompilerOptions

      public final com.oracle.truffle.compiler.TruffleCompilerOptionDescriptor[] listCompilerOptions()
    • existsCompilerOption

      public final boolean existsCompilerOption(String key)
    • validateCompilerOption

      public final String validateCompilerOption(String key, String value)
    • getTvmci

      protected OptimizedTVMCI getTvmci()
    • getTestTvmci

      protected com.oracle.truffle.api.impl.TVMCI.Test<?,?> getTestTvmci()
    • asCompilableTruffleAST

      public com.oracle.truffle.compiler.TruffleCompilable asCompilableTruffleAST(jdk.vm.ci.meta.JavaConstant constant)
      Specified by:
      asCompilableTruffleAST in interface com.oracle.truffle.compiler.TruffleCompilerRuntime
    • registerOptimizedAssumptionDependency

      public Consumer<com.oracle.truffle.compiler.OptimizedAssumptionDependency> registerOptimizedAssumptionDependency(jdk.vm.ci.meta.JavaConstant optimizedAssumptionConstant)
      Specified by:
      registerOptimizedAssumptionDependency in interface com.oracle.truffle.compiler.TruffleCompilerRuntime
    • forObject

      protected abstract jdk.vm.ci.meta.JavaConstant forObject(Object object)
    • asObject

      protected abstract <T> T asObject(Class<T> type, jdk.vm.ci.meta.JavaConstant constant)
    • newTruffleCompiler

      public final com.oracle.truffle.compiler.TruffleCompiler newTruffleCompiler()
    • getConstantFieldInfo

      public com.oracle.truffle.compiler.ConstantFieldInfo getConstantFieldInfo(jdk.vm.ci.meta.ResolvedJavaField field)
      Specified by:
      getConstantFieldInfo in interface com.oracle.truffle.compiler.TruffleCompilerRuntime
    • resolveType

      public jdk.vm.ci.meta.ResolvedJavaType resolveType(jdk.vm.ci.meta.MetaAccessProvider metaAccess, String className, boolean required)
      Specified by:
      resolveType in interface com.oracle.truffle.compiler.TruffleCompilerRuntime
    • installDefaultListeners

      protected void installDefaultListeners()
    • getHostMethodInfo

      public com.oracle.truffle.compiler.HostMethodInfo getHostMethodInfo(jdk.vm.ci.meta.ResolvedJavaMethod method)
      Specified by:
      getHostMethodInfo in interface com.oracle.truffle.compiler.TruffleCompilerRuntime
    • getPartialEvaluationMethodInfo

      public com.oracle.truffle.compiler.PartialEvaluationMethodInfo getPartialEvaluationMethodInfo(jdk.vm.ci.meta.ResolvedJavaMethod method)
      Specified by:
      getPartialEvaluationMethodInfo in interface com.oracle.truffle.compiler.TruffleCompilerRuntime
    • initializeKnownMethods

      public final void initializeKnownMethods(jdk.vm.ci.meta.MetaAccessProvider metaAccess)
    • markFrameMaterializeCalled

      public void markFrameMaterializeCalled(com.oracle.truffle.api.frame.FrameDescriptor descriptor)
      Accessor for non-public state in FrameDescriptor.
    • getFrameMaterializeCalled

      public boolean getFrameMaterializeCalled(com.oracle.truffle.api.frame.FrameDescriptor descriptor)
      Accessor for non-public state in FrameDescriptor.
    • createLoopNode

      public com.oracle.truffle.api.nodes.LoopNode createLoopNode(com.oracle.truffle.api.nodes.RepeatingNode repeatingNode)
      Specified by:
      createLoopNode in interface com.oracle.truffle.api.TruffleRuntime
    • getLoopNodeFactory

      protected final LoopNodeFactory getLoopNodeFactory()
    • getEngineCacheSupport

      public final EngineCacheSupport getEngineCacheSupport()
    • createVirtualFrame

      public final com.oracle.truffle.api.frame.VirtualFrame createVirtualFrame(Object[] arguments, com.oracle.truffle.api.frame.FrameDescriptor frameDescriptor)
      Specified by:
      createVirtualFrame in interface com.oracle.truffle.api.TruffleRuntime
    • createMaterializedFrame

      public final com.oracle.truffle.api.frame.MaterializedFrame createMaterializedFrame(Object[] arguments)
      Specified by:
      createMaterializedFrame in interface com.oracle.truffle.api.TruffleRuntime
    • createMaterializedFrame

      public final com.oracle.truffle.api.frame.MaterializedFrame createMaterializedFrame(Object[] arguments, com.oracle.truffle.api.frame.FrameDescriptor frameDescriptor)
      Specified by:
      createMaterializedFrame in interface com.oracle.truffle.api.TruffleRuntime
    • createAssumption

      public final com.oracle.truffle.api.Assumption createAssumption()
      Specified by:
      createAssumption in interface com.oracle.truffle.api.TruffleRuntime
    • createAssumption

      public final com.oracle.truffle.api.Assumption createAssumption(String name)
      Specified by:
      createAssumption in interface com.oracle.truffle.api.TruffleRuntime
    • getListener

      public final OptimizedTruffleRuntimeListener getListener()
    • iterateFrames

      public final <T> T iterateFrames(com.oracle.truffle.api.frame.FrameInstanceVisitor<T> visitor, int skipFrames)
      Specified by:
      iterateFrames in interface com.oracle.truffle.api.TruffleRuntime
    • compilationThresholdScale

      public final int compilationThresholdScale()
    • getStackIntrospection

      protected abstract jdk.vm.ci.code.stack.StackIntrospection getStackIntrospection()
    • getCapability

      public <T> T getCapability(Class<T> capability)
      Specified by:
      getCapability in interface com.oracle.truffle.api.TruffleRuntime
    • createSpeculationLog

      public abstract jdk.vm.ci.meta.SpeculationLog createSpeculationLog()
    • createOptimizedCallTarget

      protected abstract OptimizedCallTarget createOptimizedCallTarget(OptimizedCallTarget source, com.oracle.truffle.api.nodes.RootNode rootNode)
    • createInitializationCallTarget

      protected abstract OptimizedCallTarget createInitializationCallTarget(EngineData engine)
    • addListener

      public void addListener(OptimizedTruffleRuntimeListener listener)
    • removeListener

      public void removeListener(OptimizedTruffleRuntimeListener listener)
    • doCompile

      protected final void doCompile(OptimizedCallTarget callTarget, AbstractCompilationTask task)
    • getCompileQueue

      public abstract BackgroundCompileQueue getCompileQueue()
    • onEngineCreated

      protected void onEngineCreated(EngineData engine)
    • submitForCompilation

      public CompilationTask submitForCompilation(OptimizedCallTarget optimizedCallTarget, boolean lastTierCompilation)
    • finishCompilation

      public void finishCompilation(OptimizedCallTarget optimizedCallTarget, CompilationTask task, boolean mayBeAsynchronous)
    • waitForCompilation

      public void waitForCompilation(OptimizedCallTarget optimizedCallTarget, long timeout) throws ExecutionException, TimeoutException
      Throws:
      ExecutionException
      TimeoutException
    • getCompilationQueueSize

      public int getCompilationQueueSize()
    • bypassedInstalledCode

      public 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. If this runtime uses a special entry point to switch to compiled Truffle code, then this means the code with the special entry point was deoptimized or otherwise removed from the code cache and needs to be re-installed.
    • getKnownMethods

      public OptimizedTruffleRuntime.KnownMethods getKnownMethods()
    • getEngineData

      protected static EngineData getEngineData(com.oracle.truffle.api.nodes.RootNode rootNode)
      Use OptimizedCallTarget.engine whenever possible as it's much faster.
    • printStackTraceToString

      protected String printStackTraceToString(Throwable e)
    • isValueType

      public boolean isValueType(jdk.vm.ci.meta.ResolvedJavaType type)
      Specified by:
      isValueType in interface com.oracle.truffle.compiler.TruffleCompilerRuntime
    • log

      public void log(String loggerId, com.oracle.truffle.compiler.TruffleCompilable compilable, String message)
      Specified by:
      log in interface com.oracle.truffle.compiler.TruffleCompilerRuntime
    • isSuppressedFailure

      public boolean isSuppressedFailure(com.oracle.truffle.compiler.TruffleCompilable compilable, Supplier<String> serializedException)
      Specified by:
      isSuppressedFailure in interface com.oracle.truffle.compiler.TruffleCompilerRuntime
    • openCompilerThreadScope

      protected final AutoCloseable openCompilerThreadScope()
      Gets a closeable that will be used in a try-with-resources statement surrounding the run-loop of a Truffle compiler thread. In conjunction with 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.
    • getCompilerIdleDelay

      protected long getCompilerIdleDelay(OptimizedCallTarget callTarget)
      Gets the time in milliseconds an idle compiler thread will wait for new tasks before terminating. A value of <= 0 means that compiler threads block indefinitely waiting for a task and thus never terminate.
    • getObjectAlignment

      protected int getObjectAlignment()
    • getArrayBaseOffset

      protected int getArrayBaseOffset(Class<?> componentType)
    • getArrayIndexScale

      protected int getArrayIndexScale(Class<?> componentType)
    • getBaseInstanceSize

      protected int getBaseInstanceSize(Class<?> type)
    • getFieldOffsets

      protected int[] getFieldOffsets(Class<?> type, boolean includePrimitive, boolean includeSuperclasses)
    • getFastThreadLocalImpl

      protected abstract com.oracle.truffle.api.impl.AbstractFastThreadLocal getFastThreadLocalImpl()
    • getStackOverflowLimit

      public long getStackOverflowLimit()
    • createTerminatingThreadLocal

      public static <T> ThreadLocal<T> createTerminatingThreadLocal(Supplier<T> initialValue, Consumer<T> onThreadTermination)