Class SLAddNode
- All Implemented Interfaces:
com.oracle.truffle.api.instrumentation.InstrumentableNode,com.oracle.truffle.api.nodes.NodeInterface,Cloneable
Type specialization on the input values is essential for the performance. This is achieved via
node rewriting: specialized subclasses handle just a single type, so that the generic node that
can handle all types is used only in cases where different types were encountered. The subclasses
are automatically generated by the Truffle DSL. In addition, a factory class
is generated that provides, e.g., node creation.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.oracle.truffle.api.nodes.Node
com.oracle.truffle.api.nodes.Node.Child, com.oracle.truffle.api.nodes.Node.ChildrenNested classes/interfaces inherited from interface com.oracle.truffle.api.instrumentation.InstrumentableNode
com.oracle.truffle.api.instrumentation.InstrumentableNode.WrapperNode -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SLBigIntegerdoInteropBigInteger(Object left, Object right, com.oracle.truffle.api.interop.InteropLibrary leftLibrary, com.oracle.truffle.api.interop.InteropLibrary rightLibrary) This is the most general slow path of the arbitrary-precision arithmetic.static longdoLong(long left, long right) Specialization for primitivelongvalues.static SLBigIntegerdoSLBigInteger(SLBigInteger left, SLBigInteger right) This is the slow path of the arbitrary-precision arithmetic.static com.oracle.truffle.api.strings.TruffleStringdoString(Object left, Object right, com.oracle.truffle.api.nodes.Node node, SLToTruffleStringNode toTruffleStringNodeLeft, SLToTruffleStringNode toTruffleStringNodeRight, com.oracle.truffle.api.strings.TruffleString.ConcatNode concatNode) Specialization for TruffleString concatenation.static booleanGuard for TruffleString concatenation: returns true if either the left or the right operand is aTruffleString.static ObjectMethods inherited from class com.oracle.truffle.sl.nodes.SLExpressionNode
addExpressionTag, createWrapper, executeBoolean, executeGeneric, executeLong, executeVoid, hasTagMethods inherited from class com.oracle.truffle.sl.nodes.SLStatementNode
addRootTag, addStatementTag, formatSourceSection, getSourceCharIndex, getSourceEndIndex, getSourceLength, getSourceSection, hasSource, isInstrumentable, setSourceSection, setUnavailableSourceSection, toStringMethods inherited from class com.oracle.truffle.sl.nodes.local.SLScopedNode
findBlock, getVisibleVariablesIndexOnEnter, hasScope, setVisibleVariablesIndexOnEnter, setVisibleVariablesIndexOnExitMethods inherited from class com.oracle.truffle.api.nodes.Node
accept, adoptChildren, atomic, atomic, copy, deepCopy, getChildren, getCost, getDebugProperties, getDescription, getEncapsulatingSourceSection, getLock, getParent, getRootNode, insert, insert, isAdoptable, isSafelyReplaceableBy, notifyInserted, onReplace, replace, replace, reportPolymorphicSpecialize, reportReplaceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.oracle.truffle.api.instrumentation.InstrumentableNode
createProbe, findNearestNodeAt, findNearestNodeAt, findProbe, getNodeObject, materializeInstrumentableNodes
-
Constructor Details
-
SLAddNode
public SLAddNode()
-
-
Method Details
-
doLong
public static long doLong(long left, long right) Specialization for primitivelongvalues. This is the fast path of the arbitrary-precision arithmetic. We need to check for overflows of the addition, and switch to theslow path. Therefore, we use anaddition method that throws an exception on overflow. TherewriteOnattribute on theSpecializationannotation automatically triggers the node rewriting on the exception.In compiled code,
addExactis compiled to efficient machine code that uses the processor's overflow flag. Therefore, this method is compiled to only two machine code instructions on the fast path.This specialization is automatically selected by the Truffle DSL if both the left and right operand are
longvalues. -
doSLBigInteger
This is the slow path of the arbitrary-precision arithmetic. TheSLBigIntegertype of Java is doing everything we need.This specialization is automatically selected by the Truffle DSL if both the left and right operand are
SLBigIntegervalues. Because the type system defines animplicit conversionfromlongtoSLBigIntegerinSLTypes.castBigNumber(long), this specialization is also taken if the left or the right operand is alongvalue. Because thelongspecialization} has therewriteOnattribute, this specialization is also taken if both input values arelongvalues but the primitive addition overflows. -
doInteropBigInteger
public static SLBigInteger doInteropBigInteger(Object left, Object right, com.oracle.truffle.api.interop.InteropLibrary leftLibrary, com.oracle.truffle.api.interop.InteropLibrary rightLibrary) This is the most general slow path of the arbitrary-precision arithmetic. In addition to whatdoSLBigInteger(SLBigInteger, SLBigInteger)can handle, it also handles foreign objects that fit intoBigInteger, e.g. host objects representingBigIntegerinstances or big integer representations from other languages.This specialization is automatically selected by the Truffle DSL if both the left and the right operand
fitintoBigInteger, but at least one of them cannot be coverted toSLBigIntegerbyimplicit conversion. Once this specialization has been selected, it replaces thedoSLBigInteger(SLBigInteger, SLBigInteger)specialization which is then never used again. -
doString
public static com.oracle.truffle.api.strings.TruffleString doString(Object left, Object right, com.oracle.truffle.api.nodes.Node node, SLToTruffleStringNode toTruffleStringNodeLeft, SLToTruffleStringNode toTruffleStringNodeRight, com.oracle.truffle.api.strings.TruffleString.ConcatNode concatNode) Specialization for TruffleString concatenation. The SL specification says that TruffleString concatenation works if either the left or the right operand is a TruffleString. The non-string operand is converted then automatically converted to a TruffleString.To implement these semantics, we tell the Truffle DSL to use a custom guard. The guard function is defined in
this class, but could also be in any superclass. -
isString
Guard for TruffleString concatenation: returns true if either the left or the right operand is aTruffleString. -
typeError
-