Package com.oracle.truffle.api.impl
Class DefaultTruffleRuntime
- java.lang.Object
-
- com.oracle.truffle.api.impl.DefaultTruffleRuntime
-
- All Implemented Interfaces:
TruffleRuntime
public final class DefaultTruffleRuntime extends java.lang.Object implements TruffleRuntime
Default implementation of the Truffle runtime if the virtual machine does not provide a better performing alternative.This is an implementation-specific class. Do not use or instantiate it. Instead, use
Truffle.getRuntime()
to retrieve the currentTruffleRuntime
.
-
-
Constructor Summary
Constructors Constructor Description DefaultTruffleRuntime()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Assumption
createAssumption()
Creates a new assumption object that can be checked and invalidated.Assumption
createAssumption(java.lang.String name)
Creates a new assumption object with a given name that can be checked and invalidated.RootCallTarget
createCallTarget(RootNode rootNode)
Creates a new call target for a given root node.CompilerOptions
createCompilerOptions()
Creates an object which allows you to test for support of and set options specific for this runtime.DirectCallNode
createDirectCallNode(CallTarget target)
Creates a new runtime specific version ofDirectCallNode
.IndirectCallNode
createIndirectCallNode()
Creates a new runtime specific version ofIndirectCallNode
.LoopNode
createLoopNode(RepeatingNode repeating)
Experimental API.MaterializedFrame
createMaterializedFrame(java.lang.Object[] arguments)
Creates a new materialized frame object that can be used to store values.MaterializedFrame
createMaterializedFrame(java.lang.Object[] arguments, FrameDescriptor frameDescriptor)
Creates a new materialized frame object with the given frame descriptor that can be used to store values.VirtualFrame
createVirtualFrame(java.lang.Object[] arguments, FrameDescriptor frameDescriptor)
Creates a new virtual frame object that can be used to store values and is potentially optimizable by the runtime.FrameInstance
getCallerFrame()
Accesses the caller frame.java.util.Collection<RootCallTarget>
getCallTargets()
Returns a list of all still referencedRootCallTarget
instances that were created usingTruffleRuntime.createCallTarget(RootNode)
.<T> T
getCapability(java.lang.Class<T> capability)
Requests a capability from the runtime.FrameInstance
getCurrentFrame()
Accesses the current frame, i.e., the frame of the closestCallTarget
.java.lang.String
getName()
Name describing this runtime implementation for debugging purposes.<T> T
iterateFrames(FrameInstanceVisitor<T> visitor)
Accesses the current stack, i.e., the contents of theFrame
s and the associatedCallTarget
s.void
notifyTransferToInterpreter()
Internal API method.void
popFrame()
void
pushFrame(FrameInstance frame)
FrameInstance
setCurrentFrame(FrameInstance newValue)
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:TruffleRuntime
Name describing this runtime implementation for debugging purposes.- Specified by:
getName
in interfaceTruffleRuntime
- Returns:
- the name as a String
-
createCallTarget
public RootCallTarget createCallTarget(RootNode rootNode)
Description copied from interface:TruffleRuntime
Creates a new call target for a given root node.- Specified by:
createCallTarget
in interfaceTruffleRuntime
- Parameters:
rootNode
- the root node whoseRootNode.execute(com.oracle.truffle.api.frame.VirtualFrame)
method represents the entry point- Returns:
- the new call target object
-
createDirectCallNode
public DirectCallNode createDirectCallNode(CallTarget target)
Description copied from interface:TruffleRuntime
Creates a new runtime specific version ofDirectCallNode
.- Specified by:
createDirectCallNode
in interfaceTruffleRuntime
- Parameters:
target
- the directCallTarget
to call- Returns:
- the new call node
-
createIndirectCallNode
public IndirectCallNode createIndirectCallNode()
Description copied from interface:TruffleRuntime
Creates a new runtime specific version ofIndirectCallNode
.- Specified by:
createIndirectCallNode
in interfaceTruffleRuntime
- Returns:
- the new call node
-
createVirtualFrame
public VirtualFrame createVirtualFrame(java.lang.Object[] arguments, FrameDescriptor frameDescriptor)
Description copied from interface:TruffleRuntime
Creates a new virtual frame object that can be used to store values and is potentially optimizable by the runtime.- Specified by:
createVirtualFrame
in interfaceTruffleRuntime
- Returns:
- the newly created virtual frame object
-
createMaterializedFrame
public MaterializedFrame createMaterializedFrame(java.lang.Object[] arguments)
Description copied from interface:TruffleRuntime
Creates a new materialized frame object that can be used to store values.- Specified by:
createMaterializedFrame
in interfaceTruffleRuntime
- Returns:
- the newly created materialized frame object
-
createMaterializedFrame
public MaterializedFrame createMaterializedFrame(java.lang.Object[] arguments, FrameDescriptor frameDescriptor)
Description copied from interface:TruffleRuntime
Creates a new materialized frame object with the given frame descriptor that can be used to store values.- Specified by:
createMaterializedFrame
in interfaceTruffleRuntime
frameDescriptor
- the frame descriptor describing this frame's values- Returns:
- the newly created materialized frame object
-
createCompilerOptions
public CompilerOptions createCompilerOptions()
Description copied from interface:TruffleRuntime
Creates an object which allows you to test for support of and set options specific for this runtime.- Specified by:
createCompilerOptions
in interfaceTruffleRuntime
- Returns:
- the newly created compiler options object
-
createAssumption
public Assumption createAssumption()
Description copied from interface:TruffleRuntime
Creates a new assumption object that can be checked and invalidated.- Specified by:
createAssumption
in interfaceTruffleRuntime
- Returns:
- the newly created assumption object
-
createAssumption
public Assumption createAssumption(java.lang.String name)
Description copied from interface:TruffleRuntime
Creates a new assumption object with a given name that can be checked and invalidated.- Specified by:
createAssumption
in interfaceTruffleRuntime
- Parameters:
name
- the name for the new assumption- Returns:
- the newly created assumption object
-
setCurrentFrame
public FrameInstance setCurrentFrame(FrameInstance newValue)
-
pushFrame
public void pushFrame(FrameInstance frame)
-
popFrame
public void popFrame()
-
iterateFrames
public <T> T iterateFrames(FrameInstanceVisitor<T> visitor)
Description copied from interface:TruffleRuntime
Accesses the current stack, i.e., the contents of theFrame
s and the associatedCallTarget
s. Iteration starts at the caller frame, i.e., it does not include the current frame. Iteration continues as long asFrameInstanceVisitor.visitFrame(com.oracle.truffle.api.frame.FrameInstance)
, which is invoked for everyFrameInstance
, returns null. Any non-null result of the visitor indicates that frame iteration should stop.- Specified by:
iterateFrames
in interfaceTruffleRuntime
- Parameters:
visitor
- the visitor that is called for every matching frame.- Returns:
- the last result returned by the visitor (which is non-null to indicate that iteration should stop), or null if the whole stack was iterated.
-
getCallerFrame
public FrameInstance getCallerFrame()
Description copied from interface:TruffleRuntime
Accesses the caller frame. This is a convenience method that returns the first frame that is passed to the visitor ofTruffleRuntime.iterateFrames(com.oracle.truffle.api.frame.FrameInstanceVisitor<T>)
.- Specified by:
getCallerFrame
in interfaceTruffleRuntime
-
getCallTargets
public java.util.Collection<RootCallTarget> getCallTargets()
Description copied from interface:TruffleRuntime
Returns a list of all still referencedRootCallTarget
instances that were created usingTruffleRuntime.createCallTarget(RootNode)
.- Specified by:
getCallTargets
in interfaceTruffleRuntime
-
getCurrentFrame
public FrameInstance getCurrentFrame()
Description copied from interface:TruffleRuntime
Accesses the current frame, i.e., the frame of the closestCallTarget
. It is important to note that thisFrameInstance
supports only slow path access.- Specified by:
getCurrentFrame
in interfaceTruffleRuntime
-
getCapability
public <T> T getCapability(java.lang.Class<T> capability)
Description copied from interface:TruffleRuntime
Requests a capability from the runtime.- Specified by:
getCapability
in interfaceTruffleRuntime
- Parameters:
capability
- the type of the interface representing the capability- Returns:
- an implementation of the capability or
null
if the runtime does not offer it
-
notifyTransferToInterpreter
public void notifyTransferToInterpreter()
Description copied from interface:TruffleRuntime
Internal API method. Do not use.- Specified by:
notifyTransferToInterpreter
in interfaceTruffleRuntime
-
createLoopNode
public LoopNode createLoopNode(RepeatingNode repeating)
Description copied from interface:TruffleRuntime
Experimental API. May change without notice.- Specified by:
createLoopNode
in interfaceTruffleRuntime
-
-