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.
  • Method Details

    • onCodeInstallation

      void onCodeInstallation(TruffleCompilable compilable, jdk.vm.ci.code.InstalledCode installedCode)
      Notifies this runtime once installedCode has been installed in the code cache. On SubstrateVM this callback is currently unused.
      Parameters:
      compilable - the compilable to install code into
      installedCode - 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

      HostMethodInfo getHostMethodInfo(jdk.vm.ci.meta.ResolvedJavaMethod method)
      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

      ConstantFieldInfo getConstantFieldInfo(jdk.vm.ci.meta.ResolvedJavaField field)
      Gets an object describing how a read of field can 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:
      null if there are no constant folding related Truffle annotations on field
    • asCompilableTruffleAST

      TruffleCompilable asCompilableTruffleAST(jdk.vm.ci.meta.JavaConstant constant)
      Gets the TruffleCompilable represented by constant.
      Returns:
      null if constant does not represent a TruffleCompilable or it cannot be converted to a TruffleCompilable in 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, a 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.
      Parameters:
      optimizedAssumption - compiler constant representing an OptimizedAssumption
    • 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 subject
      depth - nesting depth of the event
      event - a short description of the event being traced
      properties - 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 AST
      depth - nesting depth of the event
      event - a short description of the event being traced
      subject - a description of the event's subject
      properties - name/value pairs describing properties relevant to the event
      message - optional additional message appended to the formatted event
      Since:
      20.1.0
    • log

      default void log(TruffleCompilable compilable, String message)
      Writes message followed by a new line to the Truffle logger.
      Parameters:
      compilable - the currently compiled AST
      message - message to log
    • log

      void log(String loggerId, TruffleCompilable compilable, String message)
    • 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 column
      subject - a description of the event's subject (e.g., name of a Truffle AST)
      subjectWidth - the minimum width of the subject column
      properties - name/value pairs describing properties relevant to the event
      propertyWidth - 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 as Class.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 as Class.forName(String)
      required - specifies if NoClassDefFoundError should be thrown or null should be returned if resolution fails
      Returns:
      the resolved type or null if resolution fails and required == false
      Throws:
      NoClassDefFoundError - if resolution fails and required == true
    • isValueType

      boolean isValueType(jdk.vm.ci.meta.ResolvedJavaType type)
      Determines if type is a value type. Reference comparisons (==) between value type instances have undefined semantics and can either return true or false.
    • isSuppressedFailure

      boolean isSuppressedFailure(TruffleCompilable compilable, Supplier<String> serializedException)
      Determines if the exception which happened during the compilation is suppressed and should be silent.