|
49 | 49 | import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
|
50 | 50 | import com.oracle.truffle.api.RootCallTarget;
|
51 | 51 | import com.oracle.truffle.api.dsl.Cached;
|
52 |
| -import com.oracle.truffle.api.dsl.Cached.Exclusive; |
53 | 52 | import com.oracle.truffle.api.dsl.Cached.Shared;
|
54 | 53 | import com.oracle.truffle.api.dsl.GenerateUncached;
|
55 | 54 | import com.oracle.truffle.api.dsl.NodeFactory;
|
@@ -179,16 +178,26 @@ public Object getLazyPythonClass() {
|
179 | 178 | }
|
180 | 179 |
|
181 | 180 | @ExportMessage
|
| 181 | + // Note: Avoiding calling __get__ for builtin functions seems like just an optimization, but it |
| 182 | + // is actually necessary for being able to correctly call special methods on None, because |
| 183 | + // type(None).__eq__.__get__(None, type(None)) wouldn't bind the method correctly |
182 | 184 | public Object callUnboundMethodWithState(ThreadState state, Object receiver, Object[] arguments,
|
183 | 185 | @Shared("gotState") @Cached ConditionProfile gotState,
|
184 |
| - @Exclusive @Cached CallUnboundMethodNode call) { |
| 186 | + @Shared("callMethod") @Cached CallUnboundMethodNode call) { |
185 | 187 | VirtualFrame frame = null;
|
186 | 188 | if (gotState.profile(state != null)) {
|
187 | 189 | frame = PArguments.frameForCall(state);
|
188 | 190 | }
|
189 | 191 | return call.execute(frame, this, receiver, arguments);
|
190 | 192 | }
|
191 | 193 |
|
| 194 | + @ExportMessage |
| 195 | + public Object callUnboundMethodIgnoreGetExceptionWithState(ThreadState state, Object receiver, Object[] arguments, |
| 196 | + @Shared("gotState") @Cached ConditionProfile gotState, |
| 197 | + @Shared("callMethod") @Cached CallUnboundMethodNode call) { |
| 198 | + return callUnboundMethodWithState(state, receiver, arguments, gotState, call); |
| 199 | + } |
| 200 | + |
192 | 201 | @GenerateUncached
|
193 | 202 | public abstract static class CallUnboundMethodNode extends Node {
|
194 | 203 | public abstract Object execute(Frame frame, PBuiltinFunction method, Object receiver, Object[] arguments);
|
|
0 commit comments