Package com.oracle.truffle.sl.runtime
Class SLFunction
java.lang.Object
com.oracle.truffle.sl.runtime.SLFunction
- All Implemented Interfaces:
com.oracle.truffle.api.interop.TruffleObject
public final class SLFunction
extends Object
implements com.oracle.truffle.api.interop.TruffleObject
Represents a SL function. On the Truffle level, a callable element is represented by a
call target. This class encapsulates a call target, and adds version
support: functions in SL can be redefined, i.e. changed at run time. When a function is
redefined, the call target managed by this function object is changed (and callTarget is
therefore not a final field).
Function redefinition is expected to be rare, therefore optimized call nodes want to speculate
that the call target is stable. This is possible with the help of a Truffle Assumption: a
call node can keep the call target returned by getCallTarget() cached until the
assumption returned by getCallTargetStable() is valid.
The callTarget can be null. To ensure that only one SLFunction instance
per name exists, the SLFunctionRegistry creates an instance also when performing name
lookup. A function that has been looked up, i.e., used, but not defined, has a call target that
encapsulates a SLUndefinedFunctionRootNode.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSLFunction(com.oracle.truffle.api.strings.TruffleString name, com.oracle.truffle.api.RootCallTarget callTarget) protectedSLFunction(SLLanguage language, com.oracle.truffle.api.strings.TruffleString name) -
Method Summary
Modifier and TypeMethodDescriptioncom.oracle.truffle.api.RootCallTargetcom.oracle.truffle.api.Assumptioncom.oracle.truffle.api.strings.TruffleStringgetName()protected voidsetCallTarget(com.oracle.truffle.api.RootCallTarget callTarget) toString()This method is, e.g., called when using a function literal in a string concatenation.
-
Field Details
-
INLINE_CACHE_SIZE
public static final int INLINE_CACHE_SIZE- See Also:
-
-
Constructor Details
-
SLFunction
-
SLFunction
protected SLFunction(com.oracle.truffle.api.strings.TruffleString name, com.oracle.truffle.api.RootCallTarget callTarget)
-
-
Method Details
-
getName
public com.oracle.truffle.api.strings.TruffleString getName() -
setCallTarget
protected void setCallTarget(com.oracle.truffle.api.RootCallTarget callTarget) -
getCallTarget
public com.oracle.truffle.api.RootCallTarget getCallTarget() -
getCallTargetStable
public com.oracle.truffle.api.Assumption getCallTargetStable() -
toString
This method is, e.g., called when using a function literal in a string concatenation. So changing it has an effect on SL programs.
-