public final class SLFunction extends Object implements com.oracle.truffle.api.interop.TruffleObject
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 SLFunction.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 SLFunction.getCallTarget() cached until the
assumption returned by SLFunction.getCallTargetStable() is valid.
The SLFunction.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.
| Modifier and Type | Field and Description |
|---|---|
static int |
INLINE_CACHE_SIZE |
| Modifier | Constructor and Description |
|---|---|
protected |
SLFunction(SLLanguage language,
com.oracle.truffle.api.strings.TruffleString name) |
protected |
SLFunction(com.oracle.truffle.api.strings.TruffleString name,
com.oracle.truffle.api.RootCallTarget callTarget) |
| Modifier and Type | Method and Description |
|---|---|
com.oracle.truffle.api.RootCallTarget |
getCallTarget() |
com.oracle.truffle.api.Assumption |
getCallTargetStable() |
com.oracle.truffle.api.strings.TruffleString |
getName() |
protected void |
setCallTarget(com.oracle.truffle.api.RootCallTarget callTarget) |
String |
toString()
This method is, e.g., called when using a function literal in a string concatenation.
|
public static final int INLINE_CACHE_SIZE
protected SLFunction(SLLanguage language, com.oracle.truffle.api.strings.TruffleString name)
protected SLFunction(com.oracle.truffle.api.strings.TruffleString name,
com.oracle.truffle.api.RootCallTarget callTarget)
public com.oracle.truffle.api.strings.TruffleString getName()
protected void setCallTarget(com.oracle.truffle.api.RootCallTarget callTarget)
public com.oracle.truffle.api.RootCallTarget getCallTarget()
public com.oracle.truffle.api.Assumption getCallTargetStable()