Skip to content

Commit bbe1784

Browse files
committed
[truffle] Move reflection behind a @TruffleBoundary
1 parent 4361c5c commit bbe1784

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.perl6.nqp.truffle;
2+
3+
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
4+
public class Debug {
5+
@TruffleBoundary
6+
public static RuntimeException wrongThing(String msg, Object value) {
7+
return new RuntimeException(msg + ": " + value.getClass().getCanonicalName());
8+
}
9+
}

src/vm/jvm/runtime/org/perl6/nqp/truffle/nodes/expression/NQPElemsNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.perl6.nqp.dsl.Deserializer;
77
import org.perl6.nqp.truffle.runtime.NQPHash;
88
import org.perl6.nqp.truffle.runtime.NQPList;
9+
import org.perl6.nqp.truffle.Debug;
910

1011
@NodeInfo(shortName = "elems")
1112
public final class NQPElemsNode extends NQPIntNode {
@@ -24,7 +25,7 @@ public long executeInt(VirtualFrame frame) {
2425
} else if (arg instanceof NQPHash) {
2526
return ((NQPHash)arg).elems();
2627
} else {
27-
throw new RuntimeException(arg.getClass().getCanonicalName() + " does not implement elems");
28+
throw Debug.wrongThing("does not implement elems", arg);
2829
}
2930
}
3031
}

src/vm/jvm/runtime/org/perl6/nqp/truffle/nodes/expression/NQPSmartNumifyNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import org.perl6.nqp.truffle.runtime.NQPNull;
5555

5656
import org.perl6.nqp.dsl.Deserializer;
57+
import org.perl6.nqp.truffle.Debug;
5758

5859
@NodeInfo(shortName = "smart numify")
5960
public final class NQPSmartNumifyNode extends NQPNumNode {
@@ -80,7 +81,7 @@ public double executeNum(VirtualFrame frame) {
8081
} else if (value == null) {
8182
throw new RuntimeException("can't smart numify raw null");
8283
} else {
83-
throw new RuntimeException("can't smart numify: " + value.getClass().getCanonicalName());
84+
throw Debug.wrongThing("can't smart numify", value);
8485
}
8586
}
8687
}

src/vm/jvm/runtime/org/perl6/nqp/truffle/nodes/expression/NQPSmartStringifyNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252

5353
import org.perl6.nqp.dsl.Deserializer;
5454
import org.perl6.nqp.truffle.runtime.Coercions;
55+
import org.perl6.nqp.truffle.Debug;
5556

5657
@NodeInfo(shortName = "smart stringify")
5758
public final class NQPSmartStringifyNode extends NQPStrNode {
@@ -74,7 +75,7 @@ public String executeStr(VirtualFrame frame) {
7475
} else if (value == NQPNull.SINGLETON) {
7576
return "";
7677
} else {
77-
throw new RuntimeException("can't smart stringify: " + value.getClass().getCanonicalName());
78+
throw Debug.wrongThing("can't smart stringify", value);
7879
}
7980
}
8081
}

0 commit comments

Comments
 (0)