Skip to content

Commit ce78750

Browse files
committed
Convert LongCastNode to DSL inlinable
1 parent 5106fbc commit ce78750

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/main/java/org/truffleruby/core/cast/LongCastNode.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
*/
1010
package org.truffleruby.core.cast;
1111

12+
import com.oracle.truffle.api.dsl.GenerateCached;
13+
import com.oracle.truffle.api.dsl.GenerateInline;
14+
import com.oracle.truffle.api.nodes.Node;
1215
import org.truffleruby.language.RubyBaseNode;
1316
import org.truffleruby.language.control.RaiseException;
1417

@@ -18,25 +21,27 @@
1821

1922
/** See {@link ToIntNode} for a comparison of different integer conversion nodes. */
2023
@GenerateUncached
24+
@GenerateInline
25+
@GenerateCached(false)
2126
public abstract class LongCastNode extends RubyBaseNode {
2227

23-
public abstract long executeCastLong(Object value);
28+
public abstract long executeCastLong(Node node, Object value);
2429

2530
@Specialization
26-
long doInt(int value) {
31+
static long doInt(int value) {
2732
return value;
2833
}
2934

3035
@Specialization
31-
long doLong(long value) {
36+
static long doLong(long value) {
3237
return value;
3338
}
3439

3540
@TruffleBoundary
3641
@Specialization(guards = "!isImplicitLong(value)")
37-
long doBasicObject(Object value) {
42+
static long doBasicObject(Node node, Object value) {
3843
throw new RaiseException(
39-
getContext(),
40-
coreExceptions().typeErrorIsNotA(value.toString(), "Integer (fitting in long)", this));
44+
getContext(node),
45+
coreExceptions(node).typeErrorIsNotA(value.toString(), "Integer (fitting in long)", node));
4146
}
4247
}

src/main/java/org/truffleruby/language/RubyDynamicObject.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,8 @@ public long asPointer(
516516
@Cached @Shared BranchProfile errorProfile,
517517
@Cached @Exclusive DispatchNode dispatchNode,
518518
@Cached @Shared TranslateInteropRubyExceptionNode translateRubyException,
519-
@Cached LongCastNode longCastNode) throws UnsupportedMessageException {
519+
@Cached LongCastNode longCastNode,
520+
@Bind("$node") Node node) throws UnsupportedMessageException {
520521

521522
Object value;
522523
try {
@@ -528,7 +529,7 @@ public long asPointer(
528529
errorProfile.enter();
529530
throw UnsupportedMessageException.create();
530531
}
531-
return longCastNode.executeCastLong(value);
532+
return longCastNode.executeCastLong(node, value);
532533
}
533534

534535
@ExportMessage

0 commit comments

Comments
 (0)