|
49 | 49 | import com.oracle.graal.python.nodes.ErrorMessages;
|
50 | 50 | import com.oracle.graal.python.nodes.PNodeWithContext;
|
51 | 51 | import com.oracle.graal.python.nodes.PRaiseNode;
|
| 52 | +import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; |
52 | 53 | import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode.LookupAndCallUnaryDynamicNode;
|
53 | 54 | import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes;
|
54 | 55 | import com.oracle.graal.python.nodes.util.CoerceToJavaLongNodeGen.CoerceToJavaLongExactNodeGen;
|
55 | 56 | import com.oracle.graal.python.nodes.util.CoerceToJavaLongNodeGen.CoerceToJavaLongLossyNodeGen;
|
56 | 57 | import com.oracle.graal.python.util.OverflowException;
|
57 | 58 | import com.oracle.truffle.api.CompilerAsserts;
|
58 | 59 | import com.oracle.truffle.api.CompilerDirectives;
|
| 60 | +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; |
59 | 61 | import com.oracle.truffle.api.dsl.Cached;
|
60 | 62 | import com.oracle.truffle.api.dsl.GenerateUncached;
|
61 | 63 | import com.oracle.truffle.api.dsl.ImportStatic;
|
@@ -102,8 +104,19 @@ public long toLong(PInt x) {
|
102 | 104 | @Specialization(guards = "!isNumber(x)")
|
103 | 105 | public long toLong(Object x,
|
104 | 106 | @Cached PRaiseNode raise,
|
105 |
| - @Cached LookupAndCallUnaryDynamicNode callIntNode) { |
106 |
| - Object result = callIntNode.executeObject(x, __INT__); |
| 107 | + @Cached("create(__INT__)") LookupAndCallUnaryNode callIntNode) { |
| 108 | + Object result = callIntNode.executeObject(null, x); |
| 109 | + return toLong(x, raise, result); |
| 110 | + } |
| 111 | + |
| 112 | + @TruffleBoundary |
| 113 | + @Specialization(guards = "!isNumber(x)", replaces = "toLong") |
| 114 | + public long toLongUncached(Object x) { |
| 115 | + Object result = LookupAndCallUnaryDynamicNode.getUncached().executeObject(x, __INT__); |
| 116 | + return CoerceToJavaLongNode.this.toLong(x, PRaiseNode.getUncached(), result); |
| 117 | + } |
| 118 | + |
| 119 | + private long toLong(Object x, PRaiseNode raise, Object result) { |
107 | 120 | if (result == PNone.NO_VALUE) {
|
108 | 121 | throw raise.raise(TypeError, ErrorMessages.MUST_BE_NUMERIC, x);
|
109 | 122 | }
|
|
0 commit comments