Skip to content

Commit cb0eded

Browse files
committed
Add missing callUnboundMethodIgnoreGetExceptionWithState
1 parent 269bb82 commit cb0eded

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/PBuiltinFunction.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
5050
import com.oracle.truffle.api.RootCallTarget;
5151
import com.oracle.truffle.api.dsl.Cached;
52-
import com.oracle.truffle.api.dsl.Cached.Exclusive;
5352
import com.oracle.truffle.api.dsl.Cached.Shared;
5453
import com.oracle.truffle.api.dsl.GenerateUncached;
5554
import com.oracle.truffle.api.dsl.NodeFactory;
@@ -179,16 +178,26 @@ public Object getLazyPythonClass() {
179178
}
180179

181180
@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
182184
public Object callUnboundMethodWithState(ThreadState state, Object receiver, Object[] arguments,
183185
@Shared("gotState") @Cached ConditionProfile gotState,
184-
@Exclusive @Cached CallUnboundMethodNode call) {
186+
@Shared("callMethod") @Cached CallUnboundMethodNode call) {
185187
VirtualFrame frame = null;
186188
if (gotState.profile(state != null)) {
187189
frame = PArguments.frameForCall(state);
188190
}
189191
return call.execute(frame, this, receiver, arguments);
190192
}
191193

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+
192201
@GenerateUncached
193202
public abstract static class CallUnboundMethodNode extends Node {
194203
public abstract Object execute(Frame frame, PBuiltinFunction method, Object receiver, Object[] arguments);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/PFunction.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import com.oracle.truffle.api.RootCallTarget;
4343
import com.oracle.truffle.api.Truffle;
4444
import com.oracle.truffle.api.dsl.Cached;
45-
import com.oracle.truffle.api.dsl.Cached.Exclusive;
4645
import com.oracle.truffle.api.dsl.Cached.Shared;
4746
import com.oracle.truffle.api.frame.VirtualFrame;
4847
import com.oracle.truffle.api.interop.UnsupportedMessageException;
@@ -237,11 +236,18 @@ public Object getLazyPythonClass() {
237236
@ExportMessage
238237
public Object callUnboundMethodWithState(ThreadState state, Object receiver, Object[] arguments,
239238
@Shared("gotState") @Cached ConditionProfile gotState,
240-
@Exclusive @Cached CallNode call) {
239+
@Shared("callMethod") @Cached CallNode call) {
241240
VirtualFrame frame = null;
242241
if (gotState.profile(state != null)) {
243242
frame = PArguments.frameForCall(state);
244243
}
245244
return call.execute(frame, this, PositionalArgumentsNode.prependArgument(receiver, arguments));
246245
}
246+
247+
@ExportMessage
248+
public Object callUnboundMethodIgnoreGetExceptionWithState(ThreadState state, Object receiver, Object[] arguments,
249+
@Shared("gotState") @Cached ConditionProfile gotState,
250+
@Shared("callMethod") @Cached CallNode call) {
251+
return callUnboundMethodWithState(state, receiver, arguments, gotState, call);
252+
}
247253
}

0 commit comments

Comments
 (0)