Skip to content

Commit ea0df85

Browse files
committed
cleanups in PyProcsWrapper
1 parent be04406 commit ea0df85

File tree

1 file changed

+19
-23
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi

1 file changed

+19
-23
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
import com.oracle.graal.python.util.PythonUtils;
6767
import com.oracle.truffle.api.CompilerDirectives;
6868
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
69-
import com.oracle.truffle.api.TruffleLogger;
7069
import com.oracle.truffle.api.dsl.Cached;
7170
import com.oracle.truffle.api.dsl.Cached.Exclusive;
7271
import com.oracle.truffle.api.dsl.Specialization;
@@ -83,8 +82,6 @@
8382
@ExportLibrary(value = NativeTypeLibrary.class, useForAOT = false)
8483
public abstract class PyProcsWrapper extends PythonNativeWrapper {
8584

86-
private static final TruffleLogger LOGGER = CApiContext.getLogger(PyProcsWrapper.class);
87-
8885
protected final CApiTiming timing;
8986

9087
public PyProcsWrapper(Object delegate) {
@@ -100,8 +97,7 @@ protected boolean isExecutable() {
10097
@ExportMessage
10198
@SuppressWarnings({"unused", "static-method"})
10299
protected Object execute(Object[] arguments) throws UnsupportedTypeException, ArityException, UnsupportedMessageException {
103-
CompilerDirectives.transferToInterpreterAndInvalidate();
104-
throw new IllegalStateException("should not reach");
100+
throw CompilerDirectives.shouldNotReachHere("abstract class");
105101
}
106102

107103
@ExportMessage
@@ -147,7 +143,7 @@ public GetAttrWrapper(Object delegate) {
147143

148144
@ExportMessage
149145
protected Object execute(Object[] arguments,
150-
@Cached PythonToNativeNewRefNode PythonToNativeTransferNode,
146+
@Cached PythonToNativeNewRefNode toNativeNode,
151147
@Cached CallBinaryMethodNode executeNode,
152148
@Cached NativeToPythonNode toJavaNode,
153149
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode,
@@ -160,7 +156,7 @@ protected Object execute(Object[] arguments,
160156
throw ArityException.create(2, 2, arguments.length);
161157
}
162158
try {
163-
return PythonToNativeTransferNode.execute(executeNode.executeObject(null, getDelegate(), toJavaNode.execute(arguments[0]), toJavaNode.execute(arguments[1])));
159+
return toNativeNode.execute(executeNode.executeObject(null, getDelegate(), toJavaNode.execute(arguments[0]), toJavaNode.execute(arguments[1])));
164160
} catch (Throwable t) {
165161
throw checkThrowableBeforeNative(t, "GetAttrWrapper", getDelegate());
166162
}
@@ -188,7 +184,7 @@ public BinaryFuncWrapper(Object delegate) {
188184

189185
@ExportMessage
190186
protected Object execute(Object[] arguments,
191-
@Cached PythonToNativeNewRefNode PythonToNativeTransferNode,
187+
@Cached PythonToNativeNewRefNode toNativeNode,
192188
@Cached CallBinaryMethodNode executeNode,
193189
@Cached NativeToPythonNode toJavaNode,
194190
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode,
@@ -201,7 +197,7 @@ protected Object execute(Object[] arguments,
201197
throw ArityException.create(2, 2, arguments.length);
202198
}
203199
try {
204-
return PythonToNativeTransferNode.execute(executeNode.executeObject(null, getDelegate(), toJavaNode.execute(arguments[0]), toJavaNode.execute(arguments[1])));
200+
return toNativeNode.execute(executeNode.executeObject(null, getDelegate(), toJavaNode.execute(arguments[0]), toJavaNode.execute(arguments[1])));
205201
} catch (Throwable t) {
206202
throw checkThrowableBeforeNative(t, "BinaryFuncWrapper", getDelegate());
207203
}
@@ -229,7 +225,7 @@ public UnaryFuncWrapper(Object delegate) {
229225

230226
@ExportMessage
231227
protected Object execute(Object[] arguments,
232-
@Cached PythonToNativeNewRefNode PythonToNativeTransferNode,
228+
@Cached PythonToNativeNewRefNode toNativeNode,
233229
@Cached CallUnaryMethodNode executeNode,
234230
@Cached NativeToPythonNode toJavaNode,
235231
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode,
@@ -246,7 +242,7 @@ protected Object execute(Object[] arguments,
246242
throw ArityException.create(1, 2, arguments.length);
247243
}
248244
try {
249-
return PythonToNativeTransferNode.execute(executeNode.executeObject(null, getDelegate(), toJavaNode.execute(arguments[0])));
245+
return toNativeNode.execute(executeNode.executeObject(null, getDelegate(), toJavaNode.execute(arguments[0])));
250246
} catch (Throwable t) {
251247
throw checkThrowableBeforeNative(t, "UnaryFuncWrapper", getDelegate());
252248
}
@@ -416,7 +412,7 @@ static class Execute {
416412

417413
@Specialization(guards = "arguments.length == 2")
418414
static Object init(VarargWrapper self, Object[] arguments,
419-
@Cached PythonToNativeNewRefNode PythonToNativeTransferNode,
415+
@Cached PythonToNativeNewRefNode toNativeNode,
420416
@Cached ExecutePositionalStarargsNode posStarargsNode,
421417
@Cached CallVarargsMethodNode callNode,
422418
@Cached NativeToPythonNode toJavaNode,
@@ -432,7 +428,7 @@ static Object init(VarargWrapper self, Object[] arguments,
432428

433429
Object[] starArgsArray = posStarargsNode.executeWith(null, starArgs);
434430
Object[] pArgs = PythonUtils.prependArgument(receiver, starArgsArray);
435-
return PythonToNativeTransferNode.execute(callNode.execute(null, self.getDelegate(), pArgs, PKeyword.EMPTY_KEYWORDS));
431+
return toNativeNode.execute(callNode.execute(null, self.getDelegate(), pArgs, PKeyword.EMPTY_KEYWORDS));
436432
} catch (Throwable t) {
437433
throw checkThrowableBeforeNative(t, "VarargWrapper", self.getDelegate());
438434
}
@@ -470,7 +466,7 @@ static class Execute {
470466

471467
@Specialization(guards = "arguments.length == 3")
472468
static Object init(VarargKeywordWrapper self, Object[] arguments,
473-
@Cached PythonToNativeNewRefNode PythonToNativeTransferNode,
469+
@Cached PythonToNativeNewRefNode toNativeNode,
474470
@Cached ExecutePositionalStarargsNode posStarargsNode,
475471
@Cached ExpandKeywordStarargsNode expandKwargsNode,
476472
@Cached CallVarargsMethodNode callNode,
@@ -489,7 +485,7 @@ static Object init(VarargKeywordWrapper self, Object[] arguments,
489485
Object[] starArgsArray = posStarargsNode.executeWith(null, starArgs);
490486
Object[] pArgs = PythonUtils.prependArgument(receiver, starArgsArray);
491487
PKeyword[] kwArgsArray = expandKwargsNode.execute(kwArgs);
492-
return PythonToNativeTransferNode.execute(callNode.execute(null, self.getDelegate(), pArgs, kwArgsArray));
488+
return toNativeNode.execute(callNode.execute(null, self.getDelegate(), pArgs, kwArgsArray));
493489
} catch (Throwable t) {
494490
throw checkThrowableBeforeNative(t, "VarargKeywordWrapper", self.getDelegate());
495491
}
@@ -531,7 +527,7 @@ static Object call(TernaryFunctionWrapper self, Object[] arguments,
531527
@Cached ExpandKeywordStarargsNode expandKwargsNode,
532528
@Cached CallVarargsMethodNode callNode,
533529
@Cached NativeToPythonNode toJavaNode,
534-
@Cached PythonToNativeNewRefNode PythonToNativeTransferNode,
530+
@Cached PythonToNativeNewRefNode toNativeNode,
535531
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode,
536532
@Exclusive @Cached GilNode gil) {
537533
boolean mustRelease = gil.acquire();
@@ -547,7 +543,7 @@ static Object call(TernaryFunctionWrapper self, Object[] arguments,
547543
Object[] pArgs = PythonUtils.prependArgument(receiver, starArgsArray);
548544
PKeyword[] kwArgsArray = expandKwargsNode.execute(kwArgs);
549545
Object result = callNode.execute(null, self.getDelegate(), pArgs, kwArgsArray);
550-
return PythonToNativeTransferNode.execute(result);
546+
return toNativeNode.execute(result);
551547
} catch (Throwable t) {
552548
throw checkThrowableBeforeNative(t, "TernaryFunctionWrapper", self.getDelegate());
553549
}
@@ -584,7 +580,7 @@ public RichcmpFunctionWrapper(Object delegate) {
584580
protected Object execute(Object[] arguments,
585581
@Cached NativeToPythonNode toJavaNode,
586582
@Cached CallTernaryMethodNode callNode,
587-
@Cached PythonToNativeNewRefNode PythonToNativeTransferNode,
583+
@Cached PythonToNativeNewRefNode toNativeNode,
588584
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode,
589585
@Exclusive @Cached GilNode gil) throws ArityException {
590586
boolean mustRelease = gil.acquire();
@@ -601,7 +597,7 @@ protected Object execute(Object[] arguments,
601597
Object arg2 = arguments[2];
602598

603599
Object result = callNode.execute(null, getDelegate(), arg0, arg1, arg2);
604-
return PythonToNativeTransferNode.execute(result);
600+
return toNativeNode.execute(result);
605601
} catch (Throwable t) {
606602
throw checkThrowableBeforeNative(t, "RichcmpFunctionWrapper", getDelegate());
607603
}
@@ -629,7 +625,7 @@ public SsizeargfuncWrapper(Object delegate) {
629625

630626
@ExportMessage
631627
protected Object execute(Object[] arguments,
632-
@Cached PythonToNativeNewRefNode PythonToNativeTransferNode,
628+
@Cached PythonToNativeNewRefNode toNativeNode,
633629
@Cached CallBinaryMethodNode executeNode,
634630
@Cached NativeToPythonNode toJavaNode,
635631
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode,
@@ -644,7 +640,7 @@ protected Object execute(Object[] arguments,
644640
assert arguments[1] instanceof Number;
645641
try {
646642
Object result = executeNode.executeObject(null, getDelegate(), toJavaNode.execute(arguments[0]), arguments[1]);
647-
return PythonToNativeTransferNode.execute(result);
643+
return toNativeNode.execute(result);
648644
} catch (Throwable t) {
649645
throw checkThrowableBeforeNative(t, "SsizeargfuncWrapper", getDelegate());
650646
}
@@ -767,7 +763,7 @@ static class Execute {
767763
static Object call(DescrGetFunctionWrapper self, Object[] arguments,
768764
@Cached CallTernaryMethodNode callNode,
769765
@Cached NativeToPythonNode toJavaNode,
770-
@Cached PythonToNativeNewRefNode PythonToNativeTransferNode,
766+
@Cached PythonToNativeNewRefNode toNativeNode,
771767
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode,
772768
@Exclusive @Cached GilNode gil) {
773769
boolean mustRelease = gil.acquire();
@@ -780,7 +776,7 @@ static Object call(DescrGetFunctionWrapper self, Object[] arguments,
780776
Object cls = toJavaNode.execute(arguments[2]);
781777

782778
Object result = callNode.execute(null, self.getDelegate(), receiver, obj, cls);
783-
return PythonToNativeTransferNode.execute(result);
779+
return toNativeNode.execute(result);
784780
} catch (Throwable t) {
785781
throw checkThrowableBeforeNative(t, "DescrGetFunctionWrapper", self.getDelegate());
786782
}

0 commit comments

Comments
 (0)