Interface TruffleCompilable


public interface TruffleCompilable
A Truffle AST that can be compiled by a TruffleCompiler.
  • Method Details

    • asJavaConstant

      jdk.vm.ci.meta.JavaConstant asJavaConstant()
      Gets this AST as a compiler constant.
    • getCompilationSpeculationLog

      jdk.vm.ci.meta.SpeculationLog getCompilationSpeculationLog()
      Gets a speculation log to be used for a single Truffle compilation. The returned speculation log provides access to all relevant failed speculations as well as support for making speculation during a single compilation.
    • onCompilationFailed

      void onCompilationFailed(Supplier<String> serializedException, boolean suppressed, boolean bailout, boolean permanentBailout, boolean graphTooBig)
      Notifies this object that a compilation of the AST it represents failed.
      Parameters:
      serializedException - serializedException a serialized representation of the exception representing the reason for compilation failure. See serializeException(Throwable).
      suppressed - specifies whether the failure was suppressed and should be silent. Use the TruffleCompilerRuntime.isSuppressedFailure(TruffleCompilable, Supplier) to determine if the failure should be suppressed.
      bailout - specifies whether the failure was a bailout or an error in the compiler. A bailout means the compiler aborted the compilation based on some of property of the AST (e.g., too big). A non-bailout means an unexpected error in the compiler itself.
      permanentBailout - specifies if a bailout is due to a condition that probably won't change if this AST is compiled again. This value is meaningless if bailout == false.
      graphTooBig - graph was too big
    • onCompilationSuccess

      default void onCompilationSuccess(int compilationTier, boolean lastTier)
      Called after a successful compilation of a call target.
      Parameters:
      compilationTier - which tier this compilation is compiled with
      lastTier - true if there is no next compilation tier (no next tier exists, or it is disabled)
    • onInvalidate

      boolean onInvalidate(Object source, CharSequence reason, boolean wasActive)
      Invoked when installed code associated with this AST was invalidated due to assumption invalidation. This method is not invoked across isolation boundaries, so can throw an error in such a case. Note that this method may be invoked multiple times, if multiple installed codes were active for this AST.
    • getName

      String getName()
      Gets a descriptive name for this call target.
    • getNonTrivialNodeCount

      int getNonTrivialNodeCount()
      Returns the estimate of the Truffle node count in this AST.
    • countDirectCallNodes

      int countDirectCallNodes()
      Returns the number of direct calls of a call target. This may be used by an inlining heuristic to inform exploration.
    • getCallCount

      int getCallCount()
      Return the total number of calls to this target.
    • cancelCompilation

      boolean cancelCompilation(CharSequence reason)
      Cancel the compilation of this truffle ast.
    • isSameOrSplit

      boolean isSameOrSplit(TruffleCompilable ast)
      Parameters:
      ast - the ast to compare to
      Returns:
      true if this ast and the argument are the same, one is a split of the other or they are both splits of the same ast. False otherwise.
    • getKnownCallSiteCount

      int getKnownCallSiteCount()
      Returns:
      How many direct callers is this ast known to have.
    • prepareForCompilation

      @Deprecated default void prepareForCompilation()
      Called before call target is used for runtime compilation, either as root compilation or via inlining.
    • prepareForCompilation

      default boolean prepareForCompilation(boolean rootCompilation, int compilationTier, boolean lastTier)
      Called before call target is used for runtime compilation, either as root compilation or via inlining.
      Parameters:
      rootCompilation - whether this compilation is compiled as root method
      compilationTier - which tier this compilation is compiled with
      lastTier - true if there is no next compilation tier (no next tier exists, or it is disabled).
    • serializeException

      static String serializeException(Throwable e)
      Returns e serialized as a string. The format of the returned string is:
       (class_name ":")+ "\n" stack_trace
      

      where the first class_name is e.getClass().getName() and every subsequent class_name is the super class of the previous one up to but not including Throwable. For example:

      "java.lang.NullPointerException:java.lang.RuntimeException:java.lang.Exception:\n" +
                      "java.lang.NullPointerException: compiler error\n\tat MyClass.mash(MyClass.java:9)\n\tat MyClass.main(MyClass.java:6)"
      
    • isTrivial

      boolean isTrivial()
      Returns:
      true is the root nodes of this AST trivial, false otherwise.
    • engineId

      long engineId()
      Returns a process-unique id for the underlying engine. This may be used to cache the compiler options as they are guaranteed to be the same per engine.
    • getCompilerOptions

      Map<String,String> getCompilerOptions()
      Returns a set of compiler options that where specified by the user. The compiler options are immutable for each engine.
    • getSuccessfulCompilationCount

      default int getSuccessfulCompilationCount()
      Returns the number of successful compilations of this compilable. All compilation tiers are counted together.