Class BytecodeNode

java.lang.Object
com.oracle.truffle.api.nodes.Node
com.oracle.truffle.api.bytecode.BytecodeNode
All Implemented Interfaces:
NodeInterface, Cloneable

public abstract class BytecodeNode extends Node
Represents the current bytecode for a Bytecode DSL root node. The bytecode node may be replaced over time with newer versions whenever the bytecode configuration or the tier changes.

The tier of a bytecode node initially always starts out as BytecodeTier.UNCACHED. This means that no cached nodes were created yet. The uncached threshold determines how many calls/resumes and back-edges are necessary for the node to transition to the cached tier. By default the uncached threshold is 16 if the uncached interpreter is enabled, and 0 if not (i.e., it will transition to cached on the first execution). The intention of the uncached bytecode tier is to reduce the footprint of root nodes that are executed infrequently.

The current bytecode node can be bound using @Bind BytecodeNode bytecode in the specialization of an Operation. Since the instructions for a root node can change when the bytecode node changes, a bytecode index is only valid for a particular bytecode node. It is therefore recommended to create a BytecodeLocation when storing a location (by using getBytecodeLocation(int) or binding it with @Bind BytecodeLocation location).

This class is not intended to be subclassed by clients, only by code generated by the Bytecode DSL.

Since:
24.2
See Also:
  • Constructor Details

    • BytecodeNode

      protected BytecodeNode(Object token)
      Internal constructor for generated code. Do not use.
      Since:
      24.2
  • Method Details

    • getBytecodeLocation

      public final BytecodeLocation getBytecodeLocation(Frame frame, Node location)
      Returns the current bytecode location using the current frame and location.
      Parameters:
      frame - the current frame
      location - the current location
      Returns:
      the bytecode location, or null if the frame and node do not originate from a Bytecode DSL root node.
      Since:
      24.2
    • getBytecodeLocation

      public final BytecodeLocation getBytecodeLocation(FrameInstance frameInstance)
      Gets the bytecode location associated with a particular FrameInstance obtained from a stack walk.
      Parameters:
      frameInstance - the frame instance
      Returns:
      the bytecode location, or null if the frame instance does not originate from a Bytecode DSL root node.
      Since:
      24.2
    • getBytecodeLocation

      public final BytecodeLocation getBytecodeLocation(int bytecodeIndex)
      Gets the bytecode location associated with a bytecode index. The result is only valid if the bytecode index was obtained from this bytecode node by binding $bytecodeIndex or calling getBytecodeIndex(Frame).
      Parameters:
      bytecodeIndex - the current bytecode index. A valid bytecode index can be obtained by calling BytecodeLocation.getBytecodeIndex() or using @Bind("$bytecodeIndex") annotation.
      Throws:
      IllegalArgumentException - if an invalid bytecode index was passed. This check is performed only if assertions (-ea) are enabled for performance reasons.
      Since:
      24.2
    • getBytecodeIndex

      public int getBytecodeIndex(Frame frame)
      Reads and returns the bytecode index from the frame. This method should only be called if the interpreter is configured to store the bytecode index in the frame; be sure to read the documentation before using this feature.
      Returns:
      the bytecode index stored in the frame
      Throws:
      UnsupportedOperationException - if the interpreter does not always store the bytecode index in the frame. See GenerateBytecode.storeBytecodeIndexInFrame()
      Since:
      24.2
    • getSourceLocation

      public final SourceSection getSourceLocation(Frame frame, Node location)
      Gets the most concrete source location associated with a particular location. Returns null if the node was not parsed with sources or if there is no associated source section for the given location.
      Parameters:
      frame - the current frame
      location - the current location
      Returns:
      a source section corresponding to the location. Returns null if the location is invalid or source sections are not available.
      Since:
      24.2
    • getSourceLocations

      public final SourceSection[] getSourceLocations(Frame frame, Node location)
      Gets all source locations associated with a particular location. More concrete source sections appear earlier in the array. Returns null if the node was not parsed with sources or if there is no associated source section for the given location.

      If source sections have not yet been materialized, then null is returned. Source sections may be materialized by calling ensureSourceInformation().

      Parameters:
      frame - the current frame
      location - the current location
      Returns:
      an array of source sections corresponding to the location. Returns null if the location is invalid or source sections are not available.
    • getSourceLocation

      public abstract SourceSection getSourceLocation(int bytecodeIndex)
      Finds the most concrete source location associated with the given bytecode index. The method returns null if no source section could be found.

      If source sections have not yet been materialized, then null is returned. Source sections can be materialized by calling ensureSourceInformation().

      Parameters:
      bytecodeIndex - the bytecode index, used to determine liveness of source sections. A valid bytecode index can be obtained by calling BytecodeLocation.getBytecodeIndex() or using @Bind("$bytecodeIndex") annotation. The value must be a partial evaluation constant.
      Since:
      24.2
    • getSourceLocations

      public abstract SourceSection[] getSourceLocations(int bytecodeIndex)
      Finds all source locations associated with the given bytecode index. More concrete source sections appear earlier in the array. Typically, a given section will contain the previous source section, but there is no guarantee that this the case.

      If source sections have not yet been materialized, then null is returned. Source sections can be materialized by calling ensureSourceInformation().

      Parameters:
      bytecodeIndex - the bytecode index, used to determine liveness of source sections. A valid bytecode index can be obtained by calling BytecodeLocation.getBytecodeIndex() or using @Bind("$bytecodeIndex") annotation. The value must be a partial evaluation constant.
      Since:
      24.2
    • getSourceLocation

      public final SourceSection getSourceLocation(FrameInstance frameInstance)
      Gets the source location associated with a particular frameInstance.

      If source sections have not yet been materialized, then null is returned. Source sections can be materialized by calling ensureSourceInformation().

      Parameters:
      frameInstance - the frame instance
      Returns:
      the source location, or null if a location could not be found
      Since:
      24.2
    • getSourceLocations

      public final SourceSection[] getSourceLocations(FrameInstance frameInstance)
      Gets all source locations associated with a particular frameInstance.

      If source sections have not yet been materialized, then null is returned. Source sections can be materialized by calling ensureSourceInformation().

      Parameters:
      frameInstance - the frame instance
      Returns:
      the source locations, or null if they could not be found
      Since:
      24.2
    • getBytecodeRootNode

      public final BytecodeRootNode getBytecodeRootNode()
      Returns the BytecodeRootNode to which this node belongs.
      Since:
      24.2
    • getInstruction

      public final Instruction getInstruction(int bytecodeIndex)
      Gets the instruction associated with the given bytecode index. The result is only valid if bytecodeIndex was obtained from this bytecode node by binding $bytecodeIndex or calling getBytecodeIndex(Frame).

      Compatibility note: The result of this method is subject to change without notice between Truffle versions. This introspection API is therefore intended to be used for debugging and tracing purposes only. Do not rely on instructions for your language semantics.

      Parameters:
      bytecodeIndex - the current bytecode index. A valid bytecode index can be obtained by calling BytecodeLocation.getBytecodeIndex() or using @Bind("$bytecodeIndex") annotation.
      Since:
      24.2
    • getInstructions

      public final Iterable<Instruction> getInstructions()
      Returns the current set of instructions as an Iterable.

      Compatibility note: The result of this method is subject to change without notice between Truffle versions. This introspection API is therefore intended to be used for debugging and tracing purposes only. Do not rely on instructions for your language semantics.

      Footprint note: the backing iterable implementation consumes a fixed amount of memory. It allocates the underlying instructions when it is iterated.

      Since:
      24.2
    • getInstructionsAsList

      public final List<Instruction> getInstructionsAsList()
      Returns the current set of instructions as a List with random access.

      Compatibility note: The result of this method is subject to change without notice between Truffle versions. This introspection API is therefore intended to be used for debugging and tracing purposes only. Do not rely on instructions for your language semantics.

      Footprint note: this method eagerly materializes an entire list, unlike getInstructions(), which allocates its elements on demand. Prefer to use getInstructions() for simple iteration use cases.

      Since:
      24.2
    • getSourceInformation

      public abstract List<SourceInformation> getSourceInformation()
      Produces a list of SourceInformation for a bytecode node. If no source information is available, returns null.

      Footprint note: the backing list implementation consumes a fixed amount of memory. It allocates the underlying SourceInformation elements when it is accessed.

      Since:
      24.2
    • getSourceInformationTree

      public abstract SourceInformationTree getSourceInformationTree()
      Produces a SourceInformationTree for this node. If no source information is available, returns null.

      The tree returned by this method will have a source section that spans the whole bytecode range, or a null section if no such section exists. For example, if Root operation directly contains two SourceSection operations covering different bytecode ranges, the tree's source section will be null. The source section can be null even if there is a single SourceSection operation containing the entire root body; for reliable source information that covers the entire bytecode range, the Root operation should be nested inside of a SourceSection operation.

      Footprint note: this method eagerly materializes an entire tree, unlike getSourceInformation(), which allocates its elements on demand. Prefer to use getSourceInformation() unless you need to traverse the source tree.

      Since:
      24.2
    • ensureSourceInformation

      public final BytecodeNode ensureSourceInformation()
      Ensures that sources are materialized for this node and returns an updated bytecode node if it changed during materialization.
      Since:
      24.2
      See Also:
    • hasSourceInformation

      public abstract boolean hasSourceInformation()
      Returns true if source information was materialized for this bytecode node, otherwise false.
      Since:
      24.2
      See Also:
    • getExceptionHandlers

      public abstract List<ExceptionHandler> getExceptionHandlers()
      Returns all of the exception handlers associated with this node.
      Since:
      24.2
    • getTagTree

      public abstract TagTree getTagTree()
      Returns the TagTree for this node. The tree only contains tag operations for the tags that were enabled during parsing; if no tags were enabled, returns null.
      Since:
      24.2
    • getLocalValues

      public final Object[] getLocalValues(int bytecodeIndex, Frame frame)
      Returns a new array containing the current value of each local in the frame. This method should only be used for slow-path use cases (like frame introspection). Prefer reading locals directly in the bytecode (via LoadLocal operations or LocalAccessor) when possible.

      An operation can use this method by binding the bytecode node to a specialization parameter (via @Bind("$bytecodeNode")) and then invoking the method on the bytecode node.

      The order of the locals corresponds to the order in which they were created using one of the createLocal() overloads. It is up to the language to track the creation order.

      Parameters:
      bytecodeIndex - the current bytecode index of the given frame. A valid bytecode index can be obtained by calling BytecodeLocation.getBytecodeIndex() or using @Bind("$bytecodeIndex") annotation. The value must be a partial evaluation constant. If the bytecode index is inconsistent with the state of the frame passed then the result of this method is unspecified.
      frame - the frame to read locals from
      Returns:
      an array of local values
      Since:
      24.2
      See Also:
    • getLocalValue

      public abstract Object getLocalValue(int bytecodeIndex, Frame frame, int localOffset)
      Returns the current value of the local at offset localOffset in the frame. This method should be used for uncommon scenarios, like when a node needs to read a local directly from the frame. Prefer reading locals directly in the bytecode (via LoadLocal operations or LocalAccessor) when possible.
      Parameters:
      bytecodeIndex - the current bytecode index of the given frame. A valid bytecode index can be obtained by calling BytecodeLocation.getBytecodeIndex() or using @Bind("$bytecodeIndex") annotation. The value must be a partial evaluation constant. If the bytecode index is inconsistent with the state of the frame passed then the result of this method is unspecified.
      frame - the frame to read locals from
      localOffset - the offset of the local. The offset should be between 0 and getLocalCount(int) (and may come from BytecodeLocal.getLocalOffset() or LocalVariable.getLocalOffset()). The value must be a partial evaluation constant.
      Returns:
      the current local value, or null if the local was never written to (and there is no default local value).
      Since:
      24.2
      See Also:
    • getLocalNames

      public final Object[] getLocalNames(int bytecodeIndex)
      Returns a new array containing the slot name of locals, as provided during bytecode building. If a local is not allocated using a createLocal overload that takes a name, its name will be null.

      The order of the local names corresponds to the order in which the locals were created using one of the createLocal() overloads. It is up to the language to track the creation order.

      Parameters:
      bytecodeIndex - the current bytecode index, used to determine liveness of locals. A valid bytecode index can be obtained by calling BytecodeLocation.getBytecodeIndex() or using @Bind("$bytecodeIndex") annotation. The value must be a partial evaluation constant.
      Returns:
      an array of local names
      Since:
      24.2
      See Also:
    • getLocalName

      public abstract Object getLocalName(int bytecodeIndex, int localOffset)
      Returns the name of the local at the given localOffset, as provided during bytecode building. If a local is not allocated using a createLocal overload that takes a name, its name will be null.
      Parameters:
      bytecodeIndex - the current bytecode index, used to determine liveness of locals. A valid bytecode index can be obtained by calling BytecodeLocation.getBytecodeIndex() or using @Bind("$bytecodeIndex") annotation. The value must be a partial evaluation constant.
      localOffset - the offset of the local. The offset should be between 0 and getLocalCount(int) (and may come from BytecodeLocal.getLocalOffset() or LocalVariable.getLocalOffset()). The value must be a partial evaluation constant.
      Returns:
      the local name as a partial evaluation constant
      Since:
      24.2
      See Also:
    • getLocalInfos

      public final Object[] getLocalInfos(int bytecodeIndex)
      Returns a new array containing the infos of locals, as provided during bytecode building. If a local is not allocated using a createLocal overload that takes an info, its info will be null.

      The order of the local infos corresponds to the order in which the locals were created using one of the createLocal() overloads. It is up to the language to track the creation order.

      Parameters:
      bytecodeIndex - the current bytecode index, used to determine liveness of locals. A valid bytecode index can be obtained by calling BytecodeLocation.getBytecodeIndex() or using @Bind("$bytecodeIndex") annotation. The value must be a partial evaluation constant.
      Returns:
      an array of local names
      Since:
      24.2
      See Also:
    • getLocalInfo

      public abstract Object getLocalInfo(int bytecodeIndex, int localOffset)
      Returns the info of a local, as provided during bytecode building. If a local is not allocated using a createLocal overload that takes an info, its info will be null.
      Parameters:
      bytecodeIndex - bytecodeIndex the current bytecode index, used to determine liveness of locals. A valid bytecode index can be obtained by calling BytecodeLocation.getBytecodeIndex() or using @Bind("$bytecodeIndex") annotation. The value must be a partial evaluation constant.
      localOffset - the offset of the local. The offset should be between 0 and getLocalCount(int) (and may come from BytecodeLocal.getLocalOffset() or LocalVariable.getLocalOffset()). The value must be a partial evaluation constant.
      Returns:
      the local info as a partial evaluation constant
      Since:
      24.2
      See Also:
    • setLocalValues

      public final void setLocalValues(int bytecodeIndex, Frame frame, Object[] values)
      Updates the values of the live locals in the frame. This method should be used for uncommon scenarios, like setting locals in the prolog/epilog or from another root node. Prefer setting locals directly in the bytecode (via StoreLocal operations or LocalRangeAccessor) when possible.

      Parameters:
      bytecodeIndex - the current bytecode index of the given frame. A valid bytecode index can be obtained by calling BytecodeLocation.getBytecodeIndex() or using @Bind("$bytecodeIndex") annotation. The value must be a partial evaluation constant. If the bytecode index is inconsistent with the state of the frame passed then the result of this method is unspecified.
      frame - the frame to store the local values into
      values - the values to store into the frame. The length of this array should match the number of live locals.
      Since:
      24.2
      See Also:
    • copyLocalValues

      public final void copyLocalValues(int bytecodeIndex, Frame source, Frame destination)
      Copies the values of the live locals from the source frame to the destination frame. The frames must have the same descriptor as this bytecode node.
      Parameters:
      bytecodeIndex - the current bytecode index of the given frames. A valid bytecode index can be obtained by calling BytecodeLocation.getBytecodeIndex() or using @Bind("$bytecodeIndex") annotation. The value must be a partial evaluation constant. If the bytecode index is inconsistent with the state of the frames passed then the result of this method is unspecified.
      source - the frame to copy locals from
      destination - the frame to copy locals into
      Since:
      24.2
      See Also:
    • copyLocalValues

      public final void copyLocalValues(int bytecodeIndex, Frame source, Frame destination, int localOffset, int localCount)
      Copies a range of locals from the source frame to the destination frame. The frames must have the same descriptor as this bytecode node. Compared to copyLocalValues(int, Frame, Frame), this method allows languages to selectively copy a subset of the frame's locals.

      For example, suppose that in addition to regular locals, a root node uses temporary locals for intermediate computations. Suppose also that the node needs to be able to compute the values of its regular locals (e.g., for frame introspection). This method can be used to only copy the regular locals and not the temporary locals -- assuming all of the regular locals were allocated (using createLocal()) before the temporary locals.

      Parameters:
      bytecodeIndex - the current bytecode index of the given frames. A valid bytecode index can be obtained by calling BytecodeLocation.getBytecodeIndex() or using @Bind("$bytecodeIndex") annotation. The value must be a partial evaluation constant. If the bytecode index is inconsistent with the state of the frame passed then the result of this method is unspecified.
      source - the frame to copy locals from
      destination - the frame to copy locals into
      localOffset - the offset of the first local to be copied. The offset should be between 0 and getLocalCount(int) (and may come from BytecodeLocal.getLocalOffset() or LocalVariable.getLocalOffset()). The value must be a partial evaluation constant.
      localCount - the number of locals to copy. The value must be a partial evaluation constant.
      Since:
      24.2
      See Also:
    • setLocalValue

      public abstract void setLocalValue(int bytecodeIndex, Frame frame, int localOffset, Object value)
      Updates the current value of the local at index localOffset in the frame. This method should be used for uncommon scenarios, like setting a local in the prolog/epilog or from another root node. Prefer setting locals directly in the bytecode (via StoreLocal operations or LocalAccessor) when possible.

      This method will be generated by the Bytecode DSL. Do not override.

      Parameters:
      bytecodeIndex - the current bytecode index of the given frame. A valid bytecode index can be obtained by calling BytecodeLocation.getBytecodeIndex() or using @Bind("$bytecodeIndex") annotation. The value must be a partial evaluation constant. If the bytecode index is inconsistent with the state of the frame passed then the result of this method is unspecified.
      frame - the frame to store the local value into
      localOffset - the offset of the local. The offset should be between 0 and getLocalCount(int) (and may come from BytecodeLocal.getLocalOffset() or LocalVariable.getLocalOffset()). The value must be a partial evaluation constant.
      value - the value to store into the local
      Since:
      24.2
      See Also:
    • getLocalValueInternal

      protected abstract Object getLocalValueInternal(Frame frame, int localOffset, int localIndex)
      Internal method to be implemented by generated code.
      Since:
      24.2
    • getLocalValueInternalBoolean

      protected boolean getLocalValueInternalBoolean(Frame frame, int localOffset, int localIndex) throws UnexpectedResultException
      Internal method to be implemented by generated code.
      Throws:
      UnexpectedResultException
      Since:
      24.2
    • getLocalValueInternalByte

      protected byte getLocalValueInternalByte(Frame frame, int localOffset, int localIndex) throws UnexpectedResultException
      Internal method to be implemented by generated code.
      Throws:
      UnexpectedResultException
      Since:
      24.2
    • getLocalValueInternalInt

      protected int getLocalValueInternalInt(Frame frame, int localOffset, int localIndex) throws UnexpectedResultException
      Internal method to be implemented by generated code.
      Throws:
      UnexpectedResultException
      Since:
      24.2
    • getLocalValueInternalLong

      protected long getLocalValueInternalLong(Frame frame, int localOffset, int localIndex) throws UnexpectedResultException
      Internal method to be implemented by generated code.
      Throws:
      UnexpectedResultException
      Since:
      24.2
    • getLocalValueInternalFloat

      protected float getLocalValueInternalFloat(Frame frame, int localOffset, int localIndex) throws UnexpectedResultException
      Internal method to be implemented by generated code.
      Throws:
      UnexpectedResultException
      Since:
      24.2
    • getLocalValueInternalDouble

      protected double getLocalValueInternalDouble(Frame frame, int localOffset, int localIndex) throws UnexpectedResultException
      Internal method to be implemented by generated code.
      Throws:
      UnexpectedResultException
      Since:
      24.2
    • setLocalValueInternal

      protected abstract void setLocalValueInternal(Frame frame, int localOffset, int localIndex, Object value)
      Internal method to be implemented by generated code.
      Since:
      24.2
    • setLocalValueInternalBoolean

      protected void setLocalValueInternalBoolean(Frame frame, int localOffset, int localIndex, boolean value)
      Internal method to be implemented by generated code.
      Since:
      24.2
    • setLocalValueInternalByte

      protected void setLocalValueInternalByte(Frame frame, int localOffset, int localIndex, byte value)
      Internal method to be implemented by generated code.
      Since:
      24.2
    • setLocalValueInternalInt

      protected void setLocalValueInternalInt(Frame frame, int localOffset, int localIndex, int value)
      Internal method to be implemented by generated code.
      Since:
      24.2
    • setLocalValueInternalLong

      protected void setLocalValueInternalLong(Frame frame, int localOffset, int localIndex, long value)
      Internal method to be implemented by generated code.
      Since:
      24.2
    • setLocalValueInternalFloat

      protected void setLocalValueInternalFloat(Frame frame, int localOffset, int localIndex, float value)
      Internal method to be implemented by generated code.
      Since:
      24.2
    • setLocalValueInternalDouble

      protected void setLocalValueInternalDouble(Frame frame, int localOffset, int localIndex, double value)
      Internal method to be implemented by generated code.
      Since:
      24.2
    • clearLocalValueInternal

      protected abstract void clearLocalValueInternal(Frame frame, int localOffset, int localIndex)
      Internal method to be implemented by generated code.
      Since:
      24.2
    • isLocalClearedInternal

      protected abstract boolean isLocalClearedInternal(Frame frame, int localOffset, int localIndex)
      Internal method to be implemented by generated code.
      Since:
      24.2
    • getLocalNameInternal

      protected abstract Object getLocalNameInternal(int localOffset, int localIndex)
      Internal method to be implemented by generated code.
      Since:
      24.2
    • getLocalInfoInternal

      protected abstract Object getLocalInfoInternal(int localOffset, int localIndex)
      Internal method to be implemented by generated code.
      Since:
      24.2
    • getLocalCount

      public abstract int getLocalCount(int bytecodeIndex)
      Returns the number of live locals at the given bytecodeIndex.
      Parameters:
      bytecodeIndex - the current bytecode index, used to determine liveness of locals. A valid bytecode index can be obtained by calling BytecodeLocation.getBytecodeIndex() or using @Bind("$bytecodeIndex") annotation. The value must be a partial evaluation constant.
      Returns:
      the number of live locals as a partial evaluation constant.
      Since:
      24.2
      See Also:
    • getLocals

      public abstract List<LocalVariable> getLocals()
      Returns a list of all of the local variables with liveness info.
      Returns:
      a list of locals
      Since:
      24.2
    • setUncachedThreshold

      public abstract void setUncachedThreshold(int threshold)
      Sets the number of times the uncached interpreter must be invoked/resumed or branch backwards before transitioning to cached. See GenerateBytecode.defaultUncachedThreshold() for information about the default threshold and the meaning of different threshold values.

      This method should be called before executing the root node. It will not have any effect on an uncached interpreter that is currently executing, an interpreter that is already cached, or an interpreter that does not enable uncached.

      Since:
      24.2
    • getTier

      public abstract BytecodeTier getTier()
      Returns the tier of this bytecode node.
      Since:
      24.2
    • dump

      public final String dump()
      Convert this bytecode node to a string representation for debugging purposes.
      Since:
      24.2
      See Also:
    • dump

      public final String dump(int bytecodeIndex)
      Convert this bytecode node to a string representation for debugging purposes. Highlights the location at the given bytecode index.
      Parameters:
      bytecodeIndex - an optional location to highlight in the dump.
      Since:
      24.2
    • dump

      public final String dump(BytecodeLocation highlightedLocation)
      Convert this bytecode node to a string representation for debugging purposes. Highlights the given bytecode location.
      Parameters:
      highlightedLocation - an optional location to highlight in the dump.
      Since:
      24.2
    • findInstruction

      protected abstract Instruction findInstruction(int bytecodeIndex)
      Internal method to be implemented by generated code.
      Since:
      24.2
    • findBytecodeIndex

      protected abstract int findBytecodeIndex(Frame frame, Node operationNode)
      Internal method to be implemented by generated code.
      Since:
      24.2
    • findBytecodeIndex

      protected abstract int findBytecodeIndex(FrameInstance frameInstance)
      Internal method to be implemented by generated code.
      Since:
      24.2
    • translateBytecodeIndex

      protected abstract int translateBytecodeIndex(BytecodeNode newNode, int bytecodeIndex)
      Internal method to be implemented by generated code.
      Since:
      24.2
    • validateBytecodeIndex

      protected abstract boolean validateBytecodeIndex(int bytecodeIndex)
      Internal method to be implemented by generated code.
      Since:
      24.2
    • findLocation

      protected final BytecodeLocation findLocation(int bytecodeIndex)
      Internal method called by generated code.
      Since:
      24.2
    • createDefaultStackTraceElement

      protected static final Object createDefaultStackTraceElement(TruffleStackTraceElement e)
      Internal method called by generated code.
      Since:
      24.2
    • getLocalValues

      public static Object[] getLocalValues(FrameInstance frameInstance)
      Returns a new array containing the current value of each live local in the frameInstance.
      Parameters:
      frameInstance - the frame instance
      Returns:
      a new array of local values, or null if the frame instance does not correspond to an BytecodeRootNode
      Since:
      24.2
      See Also:
    • getLocalNames

      public static Object[] getLocalNames(FrameInstance frameInstance)
      Returns a new array containing the names of the live locals in the frameInstance.
      Parameters:
      frameInstance - the frame instance
      Returns:
      a new array of names, or null if the frame instance does not correspond to an BytecodeRootNode
      Since:
      24.2
      See Also:
    • setLocalValues

      public static boolean setLocalValues(FrameInstance frameInstance, Object[] values)
      Sets the current values of the live locals in the frameInstance.
      Parameters:
      frameInstance - the frame instance
      Returns:
      whether the locals could be set with the information available in the frame instance
      Since:
      24.2
      See Also:
    • get

      public static BytecodeNode get(FrameInstance frameInstance)
      Gets the bytecode node for a given FrameInstance. Frame instances are invalid as soon as the execution of a frame is continued. A bytecode node can be used to materialize a BytecodeLocation, which can be used after the FrameInstance is no longer valid.
      Parameters:
      frameInstance - the frame instance
      Returns:
      the corresponding bytecode node or null if no node can be found.
      Since:
      24.2
    • get

      public static BytecodeNode get(Node node)
      Gets the bytecode location for a given Node, if it can be found in the parent chain.
      Parameters:
      node - the node
      Returns:
      the corresponding bytecode location or null if no location can be found.
      Since:
      24.2
    • get

      public static BytecodeNode get(TruffleStackTraceElement element)
      Gets the bytecode location for a given TruffleStackTraceElement, if it can be found using the stack trace location.
      Parameters:
      element - the stack trace element
      Returns:
      the corresponding bytecode location or null if no location can be found.
      Since:
      24.2