From dc913062485f357c209431cdf08c225d54901f48 Mon Sep 17 00:00:00 2001 From: Florian Angerer Date: Fri, 27 Feb 2026 15:51:44 +0100 Subject: [PATCH 1/3] Introduce annotation CApiUpcallTarget --- .../python/annotations/CApiUpcallTarget.java | 55 ++++++++++++++ .../processor/CApiBuiltinsProcessor.java | 74 +++++++++++++++++-- 2 files changed, 122 insertions(+), 7 deletions(-) create mode 100644 graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/CApiUpcallTarget.java diff --git a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/CApiUpcallTarget.java b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/CApiUpcallTarget.java new file mode 100644 index 0000000000..a508ffa5af --- /dev/null +++ b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/CApiUpcallTarget.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2026, 2026, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.graal.python.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Marks a method to be a possible upcall target. This will cause the C API annotation processor to + * generate the corresponding configuration for Native Image. + */ +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.METHOD) +public @interface CApiUpcallTarget { +} diff --git a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/CApiBuiltinsProcessor.java b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/CApiBuiltinsProcessor.java index 7abb35da68..d9b6ed0b26 100644 --- a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/CApiBuiltinsProcessor.java +++ b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/CApiBuiltinsProcessor.java @@ -84,6 +84,7 @@ import com.oracle.graal.python.annotations.CApiExternalFunctionSignatures; import com.oracle.graal.python.annotations.CApiFields; import com.oracle.graal.python.annotations.CApiStructs; +import com.oracle.graal.python.annotations.CApiUpcallTarget; import com.sun.source.tree.VariableTree; import com.sun.source.util.TreePathScanner; import com.sun.source.util.Trees; @@ -710,7 +711,7 @@ private void generateCApiHeader(List javaBuiltins) throws IOExc /** * Generates the native image config for the direct upcalls to the builtins. */ - private void generateUpcallConfig(List javaBuiltins) throws IOException { + private void generateUpcallConfig(List javaBuiltins, List explicitUpcallTargets) throws IOException { ArrayList lines = new ArrayList<>(); lines.add("{"); lines.add(" \"foreign\": {"); @@ -722,11 +723,31 @@ private void generateUpcallConfig(List javaBuiltins) throws IOE String classString = getUpcallTargetClass(builtin); String methodString = getUpcallTargetMethod(builtin); lines.add(" {"); - lines.add(" \"class\": \"" + classString + "\","); - lines.add(" \"method\": \"" + methodString + "\","); - lines.add(" \"returnType\": \"" + capiTypeToForeignPrimitiveType(builtin.returnType) + "\","); - lines.add(" \"parameterTypes\": [" + argString + "]"); - if (i < javaBuiltins.size() - 1) { + emitDirectUpcall(lines, classString, methodString, capiTypeToForeignPrimitiveType(builtin.returnType), argString); + if (i < javaBuiltins.size() - 1 || !explicitUpcallTargets.isEmpty()) { + lines.add(" },"); + } else { + lines.add(" }"); + } + } + for (int i = 0; i < explicitUpcallTargets.size(); i++) { + ExecutableElement explicitUpcallTarget = explicitUpcallTargets.get(i); + + if (!verifySignatureOfExplicitUpcallTarget(explicitUpcallTarget)) { + continue; + } + + Element enclosingElement = explicitUpcallTarget.getEnclosingElement(); + if (enclosingElement.getKind() != ElementKind.CLASS) { + processingEnv.getMessager().printError("Method is expected to be enclosed by a class", explicitUpcallTarget); + continue; + } + String classString = processingEnv.getElementUtils().getBinaryName((TypeElement) enclosingElement).toString(); + String methodString = explicitUpcallTarget.getSimpleName().toString(); + String argString = explicitUpcallTarget.getParameters().stream().map(VariableElement::asType).map(t -> '"' + toJNIName(t) + '"').collect(Collectors.joining(", ")); + lines.add(" {"); + emitDirectUpcall(lines, classString, methodString, explicitUpcallTarget.getReturnType().toString(), argString); + if (i < explicitUpcallTargets.size() - 1) { lines.add(" },"); } else { lines.add(" }"); @@ -757,6 +778,37 @@ private static String getUpcallTargetMethod(CApiBuiltinDesc builtin) { return builtin.origin.getSimpleName().toString(); } + private static void emitDirectUpcall(ArrayList lines, String classString, String methodString, String returnType, String argString) { + lines.add(" \"class\": \"" + classString + "\","); + lines.add(" \"method\": \"" + methodString + "\","); + lines.add(" \"returnType\": \"" + returnType + "\","); + lines.add(" \"parameterTypes\": [" + argString + "]"); + } + + private static String toJNIName(TypeMirror typeMirror) { + assert typeMirror.getKind().isPrimitive(); + if (typeMirror.getKind() == TypeKind.VOID) { + return "void"; + } + return "j" + typeMirror; + } + + private boolean verifySignatureOfExplicitUpcallTarget(ExecutableElement explicitUpcallTarget) { + if (!explicitUpcallTarget.getReturnType().getKind().isPrimitive()) { + processingEnv.getMessager().printError("Return type must be primitive but was " + explicitUpcallTarget.getReturnType(), explicitUpcallTarget); + return false; + } + + for (int i = 0; i < explicitUpcallTarget.getParameters().size(); i++) { + VariableElement variableElement = explicitUpcallTarget.getParameters().get(i); + if (!variableElement.asType().getKind().isPrimitive()) { + processingEnv.getMessager().printError("Parameter type must be primitive but was " + variableElement.asType(), variableElement); + return false; + } + } + return true; + } + /** * Generates the contents of the PythonCextBuiltinRegistry class: the list of builtins, the * CApiBuiltinNode factory function, and the slot query function. @@ -2008,6 +2060,14 @@ public boolean process(Set annotations, RoundEnvironment } } } + List explicitUpcallTargets = new LinkedList<>(); + for (var el : re.getElementsAnnotatedWith(CApiUpcallTarget.class)) { + if (el.getKind() == ElementKind.METHOD) { + explicitUpcallTargets.add((ExecutableElement) el); + } else { + processingEnv.getMessager().printError(CApiUpcallTarget.class.getSimpleName() + " is only applicable for methods.", el); + } + } Map sigs = new HashMap<>(); for (var el : re.getElementsAnnotatedWith(CApiExternalFunctionSignatures.class)) { if (el.getKind() == ElementKind.ENUM) { @@ -2038,7 +2098,7 @@ public boolean process(Set annotations, RoundEnvironment generateExternalFunctionRootNodes(externalFunctionDescs, cApiExternalFunctionWrapperDescs, sigs); } generateBuiltinRegistry(javaBuiltins); - generateUpcallConfig(javaBuiltins); + generateUpcallConfig(javaBuiltins, explicitUpcallTargets); generateCApiAsserts(allBuiltins); if (trees != null) { // needs jdk.compiler From 068f309667a683046cb6f644a1f1cdf6fbddb19e Mon Sep 17 00:00:00 2001 From: Florian Angerer Date: Fri, 27 Feb 2026 15:53:24 +0100 Subject: [PATCH 2/3] Use findVirtual and bind receiver in PyCFunctionWrapper --- .../objects/cext/capi/PyCFunctionWrapper.java | 84 ++++++++++--------- 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyCFunctionWrapper.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyCFunctionWrapper.java index b4c4af000a..8890221a5c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyCFunctionWrapper.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyCFunctionWrapper.java @@ -49,6 +49,7 @@ import java.lang.invoke.MethodType; import com.oracle.graal.python.annotations.Builtin; +import com.oracle.graal.python.annotations.CApiUpcallTarget; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTiming; import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.NativeToPythonInternalNode; @@ -97,13 +98,14 @@ public abstract class PyCFunctionWrapper { static { try { - HANDLE_UNARY = MethodHandles.lookup().findStatic(PyCFunctionUnaryWrapper.class, "executeUnary", MethodType.methodType(long.class, PyCFunctionUnaryWrapper.class, long.class)); - HANDLE_BINARY = MethodHandles.lookup().findStatic(PyCFunctionBinaryWrapper.class, "executeBinary", - MethodType.methodType(long.class, PyCFunctionBinaryWrapper.class, long.class, long.class)); - HANDLE_VARARGS = MethodHandles.lookup().findStatic(PyCFunctionVarargsWrapper.class, "executeVarargs", - MethodType.methodType(long.class, PyCFunctionVarargsWrapper.class, long.class, long.class)); - HANDLE_KEYWORDS = MethodHandles.lookup().findStatic(PyCFunctionKeywordsWrapper.class, "executeKeywords", - MethodType.methodType(long.class, PyCFunctionKeywordsWrapper.class, long.class, long.class, long.class)); + HANDLE_UNARY = MethodHandles.lookup().findVirtual(PyCFunctionUnaryWrapper.class, + "executeUnary", MethodType.methodType(long.class, long.class)); + HANDLE_BINARY = MethodHandles.lookup().findVirtual(PyCFunctionBinaryWrapper.class, + "executeBinary", MethodType.methodType(long.class, long.class, long.class)); + HANDLE_VARARGS = MethodHandles.lookup().findVirtual(PyCFunctionVarargsWrapper.class, + "executeVarargs", MethodType.methodType(long.class, long.class, long.class)); + HANDLE_KEYWORDS = MethodHandles.lookup().findVirtual(PyCFunctionKeywordsWrapper.class, + "executeKeywords", MethodType.methodType(long.class, long.class, long.class, long.class)); } catch (NoSuchMethodException | IllegalAccessException e) { throw new RuntimeException(e); } @@ -193,30 +195,31 @@ public static PyCFunctionWrapper createFromBuiltinFunction(CApiContext cApiConte } } - static final class PyCFunctionUnaryWrapper extends PyCFunctionWrapper { + public static final class PyCFunctionUnaryWrapper extends PyCFunctionWrapper { PyCFunctionUnaryWrapper(RootCallTarget callTarget, Signature signature, Object[] defaults) { super(callTarget, signature, defaults, SIGNATURE_1_ARG, HANDLE_UNARY); } - @SuppressWarnings("try") - private static long executeUnary(PyCFunctionUnaryWrapper self, long arg0) { + @CApiUpcallTarget + @SuppressWarnings({"try", "unused"}) + public long executeUnary(long arg0) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { Object jArg0 = NativeToPythonInternalNode.executeUncached(arg0, false); - Object[] pArgs = CreateArgumentsNode.executeUncached(self.callTargetName, PythonUtils.EMPTY_OBJECT_ARRAY, PKeyword.EMPTY_KEYWORDS, self.signature, jArg0, null, - self.defaults, PKeyword.EMPTY_KEYWORDS, false); - Object result = SimpleIndirectInvokeNode.executeUncached(self.callTarget, pArgs); + Object[] pArgs = CreateArgumentsNode.executeUncached(callTargetName, PythonUtils.EMPTY_OBJECT_ARRAY, PKeyword.EMPTY_KEYWORDS, signature, jArg0, null, + defaults, PKeyword.EMPTY_KEYWORDS, false); + Object result = SimpleIndirectInvokeNode.executeUncached(callTarget, pArgs); return PythonToNativeNewRefNode.executeLongUncached(result); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, self.toString(), ""); + throw checkThrowableBeforeNative(t, toString(), ""); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return NULLPTR; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -226,31 +229,32 @@ protected String getFlagsRepr() { } } - static final class PyCFunctionBinaryWrapper extends PyCFunctionWrapper { + public static final class PyCFunctionBinaryWrapper extends PyCFunctionWrapper { PyCFunctionBinaryWrapper(RootCallTarget callTarget, Signature signature, Object[] defaults) { super(callTarget, signature, defaults, SIGNATURE_2_ARG, HANDLE_BINARY); } - @SuppressWarnings("try") - private static long executeBinary(PyCFunctionBinaryWrapper self, long arg0, long arg1) { + @CApiUpcallTarget + @SuppressWarnings({"try", "unused"}) + public long executeBinary(long arg0, long arg1) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { Object jArg0 = NativeToPythonInternalNode.executeUncached(arg0, false); Object jArg1 = NativeToPythonInternalNode.executeUncached(arg1, false); - Object[] pArgs = CreateArgumentsNode.executeUncached(self.callTargetName, new Object[]{jArg1}, PKeyword.EMPTY_KEYWORDS, self.signature, jArg0, null, - self.defaults, PKeyword.EMPTY_KEYWORDS, false); - Object result = SimpleIndirectInvokeNode.executeUncached(self.callTarget, pArgs); + Object[] pArgs = CreateArgumentsNode.executeUncached(callTargetName, new Object[]{jArg1}, PKeyword.EMPTY_KEYWORDS, signature, jArg0, null, + defaults, PKeyword.EMPTY_KEYWORDS, false); + Object result = SimpleIndirectInvokeNode.executeUncached(callTarget, pArgs); return PythonToNativeNewRefNode.executeLongUncached(result); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, self.toString(), ""); + throw checkThrowableBeforeNative(t, toString(), ""); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return NULLPTR; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -260,32 +264,33 @@ protected String getFlagsRepr() { } } - static final class PyCFunctionVarargsWrapper extends PyCFunctionWrapper { + public static final class PyCFunctionVarargsWrapper extends PyCFunctionWrapper { PyCFunctionVarargsWrapper(RootCallTarget callTarget, Signature signature, Object[] defaults) { super(callTarget, signature, defaults, SIGNATURE_2_ARG, HANDLE_VARARGS); } - @SuppressWarnings("try") - private static long executeVarargs(PyCFunctionVarargsWrapper self, long arg0, long arg1) { + @CApiUpcallTarget + @SuppressWarnings({"try", "unused"}) + public long executeVarargs(long arg0, long arg1) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { Object receiver = NativeToPythonInternalNode.executeUncached(arg0, false); Object starArgs = NativeToPythonInternalNode.executeUncached(arg1, false); Object[] starArgsArray = ExecutePositionalStarargsNode.executeUncached(starArgs); - Object[] pArgs = CreateArgumentsNode.executeUncached(self.callTargetName, starArgsArray, PKeyword.EMPTY_KEYWORDS, self.signature, receiver, null, - self.defaults, PKeyword.EMPTY_KEYWORDS, false); - Object result = SimpleIndirectInvokeNode.executeUncached(self.callTarget, pArgs); + Object[] pArgs = CreateArgumentsNode.executeUncached(callTargetName, starArgsArray, PKeyword.EMPTY_KEYWORDS, signature, receiver, null, + defaults, PKeyword.EMPTY_KEYWORDS, false); + Object result = SimpleIndirectInvokeNode.executeUncached(callTarget, pArgs); return PythonToNativeNewRefNode.executeLongUncached(result); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, self.toString(), ""); + throw checkThrowableBeforeNative(t, toString(), ""); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return NULLPTR; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -295,14 +300,15 @@ protected String getFlagsRepr() { } } - static final class PyCFunctionKeywordsWrapper extends PyCFunctionWrapper { + public static final class PyCFunctionKeywordsWrapper extends PyCFunctionWrapper { PyCFunctionKeywordsWrapper(RootCallTarget callTarget, Signature signature, Object[] defaults) { super(callTarget, signature, defaults, SIGNATURE_3_ARG, HANDLE_KEYWORDS); } - @SuppressWarnings("try") - private static long executeKeywords(PyCFunctionKeywordsWrapper self, long arg0, long arg1, long arg2) { + @CApiUpcallTarget + @SuppressWarnings({"try", "unused"}) + public long executeKeywords(long arg0, long arg1, long arg2) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { @@ -311,18 +317,18 @@ private static long executeKeywords(PyCFunctionKeywordsWrapper self, long arg0, Object kwArgs = NativeToPythonInternalNode.executeUncached(arg2, false); Object[] starArgsArray = ExecutePositionalStarargsNode.executeUncached(starArgs); PKeyword[] kwArgsArray = ExpandKeywordStarargsNode.getUncached().execute(null, kwArgs); - Object[] pArgs = CreateArgumentsNode.executeUncached(self.callTargetName, starArgsArray, kwArgsArray, self.signature, receiver, null, - self.defaults, PKeyword.EMPTY_KEYWORDS, false); - Object result = SimpleIndirectInvokeNode.executeUncached(self.callTarget, pArgs); + Object[] pArgs = CreateArgumentsNode.executeUncached(callTargetName, starArgsArray, kwArgsArray, signature, receiver, null, + defaults, PKeyword.EMPTY_KEYWORDS, false); + Object result = SimpleIndirectInvokeNode.executeUncached(callTarget, pArgs); return PythonToNativeNewRefNode.executeLongUncached(result); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, self.toString(), ""); + throw checkThrowableBeforeNative(t, toString(), ""); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return NULLPTR; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } From b47fd3a803e2d6ca8fb7ac005003dcbb9eab49f4 Mon Sep 17 00:00:00 2001 From: Florian Angerer Date: Wed, 6 May 2026 10:24:46 +0200 Subject: [PATCH 3/3] Use findVirtual and bind receiver in TpSlotWrapper --- .../objects/cext/capi/TpSlotWrapper.java | 264 ++++++++++-------- 1 file changed, 149 insertions(+), 115 deletions(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/TpSlotWrapper.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/TpSlotWrapper.java index c05ce0f87b..c10a23c3e6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/TpSlotWrapper.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/TpSlotWrapper.java @@ -52,6 +52,7 @@ import java.lang.invoke.MethodType; import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.annotations.CApiUpcallTarget; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTiming; @@ -137,37 +138,49 @@ public abstract class TpSlotWrapper { static { try { - HANDLE_GET_ATTR = MethodHandles.lookup().findStatic(GetAttrWrapper.class, "executeGetAttr", MethodType.methodType(long.class, GetAttrWrapper.class, long.class, long.class)); - HANDLE_BINARY_SLOT_FUNC = MethodHandles.lookup().findStatic(BinarySlotFuncWrapper.class, "executeBinarySlot", - MethodType.methodType(long.class, BinarySlotFuncWrapper.class, long.class, long.class)); - HANDLE_BINARY_OP_SLOT_FUNC = MethodHandles.lookup().findStatic(BinaryOpSlotFuncWrapper.class, "executeBinaryOpSlot", - MethodType.methodType(long.class, BinaryOpSlotFuncWrapper.class, long.class, long.class)); - HANDLE_UNARY_FUNC = MethodHandles.lookup().findStatic(UnaryFuncWrapper.class, "executeUnary", MethodType.methodType(long.class, UnaryFuncWrapper.class, long.class)); - HANDLE_ITER_NEXT = MethodHandles.lookup().findStatic(IterNextWrapper.class, "executeIterNext", MethodType.methodType(long.class, IterNextWrapper.class, long.class)); - HANDLE_INQUIRY = MethodHandles.lookup().findStatic(InquiryWrapper.class, "executeInquiry", MethodType.methodType(int.class, InquiryWrapper.class, long.class)); - HANDLE_SQ_CONTAINS = MethodHandles.lookup().findStatic(SqContainsWrapper.class, "executeSqContains", MethodType.methodType(int.class, SqContainsWrapper.class, long.class, long.class)); - HANDLE_OBJ_OBJ_ARG = MethodHandles.lookup().findStatic(ObjobjargWrapper.class, "executeObjobjarg", - MethodType.methodType(int.class, ObjobjargWrapper.class, long.class, long.class, long.class)); - HANDLE_SET_ATTR = MethodHandles.lookup().findStatic(SetAttrWrapper.class, "executeSetAttr", - MethodType.methodType(int.class, SetAttrWrapper.class, long.class, long.class, long.class)); - HANDLE_DESCR_SET_FUNCTION = MethodHandles.lookup().findStatic(DescrSetFunctionWrapper.class, "executeDescrSetFunction", - MethodType.methodType(int.class, DescrSetFunctionWrapper.class, long.class, long.class, long.class)); - HANDLE_INIT = MethodHandles.lookup().findStatic(InitWrapper.class, "executeInit", MethodType.methodType(int.class, InitWrapper.class, long.class, long.class, long.class)); - HANDLE_NEW = MethodHandles.lookup().findStatic(NewWrapper.class, "executeNew", MethodType.methodType(long.class, NewWrapper.class, long.class, long.class, long.class)); - HANDLE_CALL = MethodHandles.lookup().findStatic(CallWrapper.class, "executeCall", MethodType.methodType(long.class, CallWrapper.class, long.class, long.class, long.class)); - HANDLE_NB_POWER = MethodHandles.lookup().findStatic(NbPowerWrapper.class, "executeNbPower", MethodType.methodType(long.class, NbPowerWrapper.class, long.class, long.class, long.class)); - HANDLE_NB_IN_PLACE_POWER = MethodHandles.lookup().findStatic(NbInPlacePowerWrapper.class, "executeNbInPlacePower", - MethodType.methodType(long.class, NbInPlacePowerWrapper.class, long.class, long.class, long.class)); - HANDLE_RICHCMP_FUNCTION = MethodHandles.lookup().findStatic(RichcmpFunctionWrapper.class, "executeRichcmpFunction", - MethodType.methodType(long.class, RichcmpFunctionWrapper.class, long.class, long.class, int.class)); - HANDLE_SSIZEARGFUNC_SLOT = MethodHandles.lookup().findStatic(SsizeargfuncSlotWrapper.class, "executeSsizeargfuncSlot", - MethodType.methodType(long.class, SsizeargfuncSlotWrapper.class, long.class, long.class)); - HANDLE_SSIZEOBJARGPROC = MethodHandles.lookup().findStatic(SsizeobjargprocWrapper.class, "executeSsizeobjargproc", - MethodType.methodType(int.class, SsizeobjargprocWrapper.class, long.class, long.class, long.class)); - HANDLE_LENFUNC = MethodHandles.lookup().findStatic(LenfuncWrapper.class, "executeLenfunc", MethodType.methodType(long.class, LenfuncWrapper.class, long.class)); - HANDLE_HASHFUNC = MethodHandles.lookup().findStatic(HashfuncWrapper.class, "executeHashfunc", MethodType.methodType(long.class, HashfuncWrapper.class, long.class)); - HANDLE_DESCR_GET_FUNCTION = MethodHandles.lookup().findStatic(DescrGetFunctionWrapper.class, "executeDescrGetFunction", - MethodType.methodType(long.class, DescrGetFunctionWrapper.class, long.class, long.class, long.class)); + MethodHandles.Lookup lookup = MethodHandles.lookup(); + HANDLE_GET_ATTR = lookup.findVirtual(GetAttrWrapper.class, "executeGetAttr", + MethodType.methodType(long.class, long.class, long.class)); + HANDLE_BINARY_SLOT_FUNC = lookup.findVirtual(BinarySlotFuncWrapper.class, "executeBinarySlot", + MethodType.methodType(long.class, long.class, long.class)); + HANDLE_BINARY_OP_SLOT_FUNC = lookup.findVirtual(BinaryOpSlotFuncWrapper.class, "executeBinaryOpSlot", + MethodType.methodType(long.class, long.class, long.class)); + HANDLE_UNARY_FUNC = lookup.findVirtual(UnaryFuncWrapper.class, "executeUnary", + MethodType.methodType(long.class, long.class)); + HANDLE_ITER_NEXT = lookup.findVirtual(IterNextWrapper.class, "executeIterNext", + MethodType.methodType(long.class, long.class)); + HANDLE_INQUIRY = lookup.findVirtual(InquiryWrapper.class, "executeInquiry", + MethodType.methodType(int.class, long.class)); + HANDLE_SQ_CONTAINS = lookup.findVirtual(SqContainsWrapper.class, "executeSqContains", + MethodType.methodType(int.class, long.class, long.class)); + HANDLE_OBJ_OBJ_ARG = lookup.findVirtual(ObjobjargWrapper.class, "executeObjobjarg", + MethodType.methodType(int.class, long.class, long.class, long.class)); + HANDLE_SET_ATTR = lookup.findVirtual(SetAttrWrapper.class, "executeSetAttr", + MethodType.methodType(int.class, long.class, long.class, long.class)); + HANDLE_DESCR_SET_FUNCTION = lookup.findVirtual(DescrSetFunctionWrapper.class, "executeDescrSetFunction", + MethodType.methodType(int.class, long.class, long.class, long.class)); + HANDLE_INIT = lookup.findVirtual(InitWrapper.class, "executeInit", + MethodType.methodType(int.class, long.class, long.class, long.class)); + HANDLE_NEW = lookup.findVirtual(NewWrapper.class, "executeNew", + MethodType.methodType(long.class, long.class, long.class, long.class)); + HANDLE_CALL = lookup.findVirtual(CallWrapper.class, "executeCall", + MethodType.methodType(long.class, long.class, long.class, long.class)); + HANDLE_NB_POWER = lookup.findVirtual(NbPowerWrapper.class, "executeNbPower", + MethodType.methodType(long.class, long.class, long.class, long.class)); + HANDLE_NB_IN_PLACE_POWER = lookup.findVirtual(NbInPlacePowerWrapper.class, "executeNbInPlacePower", + MethodType.methodType(long.class, long.class, long.class, long.class)); + HANDLE_RICHCMP_FUNCTION = lookup.findVirtual(RichcmpFunctionWrapper.class, "executeRichcmpFunction", + MethodType.methodType(long.class, long.class, long.class, int.class)); + HANDLE_SSIZEARGFUNC_SLOT = lookup.findVirtual(SsizeargfuncSlotWrapper.class, "executeSsizeargfuncSlot", + MethodType.methodType(long.class, long.class, long.class)); + HANDLE_SSIZEOBJARGPROC = lookup.findVirtual(SsizeobjargprocWrapper.class, "executeSsizeobjargproc", + MethodType.methodType(int.class, long.class, long.class, long.class)); + HANDLE_LENFUNC = lookup.findVirtual(LenfuncWrapper.class, "executeLenfunc", + MethodType.methodType(long.class, long.class)); + HANDLE_HASHFUNC = lookup.findVirtual(HashfuncWrapper.class, "executeHashfunc", + MethodType.methodType(long.class, long.class)); + HANDLE_DESCR_GET_FUNCTION = lookup.findVirtual(DescrGetFunctionWrapper.class, "executeDescrGetFunction", + MethodType.methodType(long.class, long.class, long.class, long.class)); } catch (NoSuchMethodException | IllegalAccessException e) { throw new RuntimeException(e); } @@ -211,23 +224,24 @@ public GetAttrWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_P_PP, HANDLE_GET_ATTR); } + @CApiUpcallTarget @SuppressWarnings("try") - private static long executeGetAttr(GetAttrWrapper self, long arg0, long arg1) { + private long executeGetAttr(long arg0, long arg1) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { Object jArg0 = NativeToPythonInternalNode.executeUncached(arg0, false); Object jArg1 = NativeToPythonInternalNode.executeUncached(arg1, false); - Object result = CallManagedSlotGetAttrNode.executeUncached(self.getSlot(), jArg0, jArg1); + Object result = CallManagedSlotGetAttrNode.executeUncached(getSlot(), jArg0, jArg1); return PythonToNativeNewRefNode.executeLongUncached(result); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "GetAttrWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "GetAttrWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return NULLPTR; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -243,23 +257,24 @@ public BinarySlotFuncWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_P_PP, HANDLE_BINARY_SLOT_FUNC); } + @CApiUpcallTarget @SuppressWarnings("try") - private static long executeBinarySlot(BinarySlotFuncWrapper self, long arg0, long arg1) { + private long executeBinarySlot(long arg0, long arg1) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { Object jArg0 = NativeToPythonInternalNode.executeUncached(arg0, false); Object jArg1 = NativeToPythonInternalNode.executeUncached(arg1, false); - Object result = CallSlotBinaryFuncNode.executeUncached(self.getSlot(), jArg0, jArg1); + Object result = CallSlotBinaryFuncNode.executeUncached(getSlot(), jArg0, jArg1); return PythonToNativeNewRefNode.executeLongUncached(result); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "BinarySlotFuncWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "BinarySlotFuncWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return NULLPTR; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -329,8 +344,9 @@ public static BinaryOpSlotFuncWrapper createMatrixMultiply(TpSlotManaged slot) { return new BinaryOpSlotFuncWrapper(slot, ReversibleSlot.NB_MATRIX_MULTIPLY); } + @CApiUpcallTarget @SuppressWarnings("try") - private static long executeBinaryOpSlot(BinaryOpSlotFuncWrapper self, long arg0, long arg1) { + private long executeBinaryOpSlot(long arg0, long arg1) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { @@ -338,18 +354,18 @@ private static long executeBinaryOpSlot(BinaryOpSlotFuncWrapper self, long arg0, Object other = NativeToPythonInternalNode.executeUncached(arg1, false); Object otherType = GetClassNode.executeUncached(other); Object receiverType = GetClassNode.executeUncached(receiver); - TpSlot otherSlot = self.binaryOp.getSlotValue(GetTpSlotsNode.executeUncached(otherType)); + TpSlot otherSlot = binaryOp.getSlotValue(GetTpSlotsNode.executeUncached(otherType)); boolean sameTypes = IsSameTypeNode.executeUncached(receiverType, otherType); - Object result = CallSlotBinaryOpNode.executeUncached(self.getSlot(), receiver, receiverType, other, otherSlot, otherType, sameTypes, self.binaryOp); + Object result = CallSlotBinaryOpNode.executeUncached(getSlot(), receiver, receiverType, other, otherSlot, otherType, sameTypes, binaryOp); return PythonToNativeNewRefNode.executeLongUncached(result); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "BinaryOpSlotFuncWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "BinaryOpSlotFuncWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return NULLPTR; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -365,22 +381,23 @@ public UnaryFuncWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_P_P, HANDLE_UNARY_FUNC); } + @CApiUpcallTarget @SuppressWarnings("try") - private static long executeUnary(UnaryFuncWrapper self, long arg0) { + private long executeUnary(long arg0) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { Object jArg0 = NativeToPythonInternalNode.executeUncached(arg0, false); - Object result = CallSlotUnaryNode.executeUncached(self.getSlot(), jArg0); + Object result = CallSlotUnaryNode.executeUncached(getSlot(), jArg0); return PythonToNativeNewRefNode.executeLongUncached(result); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "UnaryFuncWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "UnaryFuncWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return NULLPTR; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -396,27 +413,28 @@ public IterNextWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_P_P, HANDLE_ITER_NEXT); } + @CApiUpcallTarget @SuppressWarnings("try") - private static long executeIterNext(IterNextWrapper self, long arg0) { + private long executeIterNext(long arg0) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { Object result; try { Object jArg0 = NativeToPythonInternalNode.executeUncached(arg0, false); - result = CallSlotTpIterNextNode.executeUncached(self.getSlot(), jArg0); + result = CallSlotTpIterNextNode.executeUncached(getSlot(), jArg0); } catch (IteratorExhausted e) { return NULLPTR; } return PythonToNativeNewRefNode.executeLongUncached(result); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "IterNextWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "IterNextWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return NULLPTR; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -431,21 +449,22 @@ public InquiryWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_I_P, HANDLE_INQUIRY); } + @CApiUpcallTarget @SuppressWarnings("try") - private static int executeInquiry(InquiryWrapper self, long arg0) { + private int executeInquiry(long arg0) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { Object jArg0 = NativeToPythonInternalNode.executeUncached(arg0, false); - return CallSlotNbBoolNode.executeUncached(self.getSlot(), jArg0) ? 1 : 0; + return CallSlotNbBoolNode.executeUncached(getSlot(), jArg0) ? 1 : 0; } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "InquiryWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "InquiryWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return -1; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -460,22 +479,23 @@ public SqContainsWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_I_PP, HANDLE_SQ_CONTAINS); } + @CApiUpcallTarget @SuppressWarnings("try") - private static int executeSqContains(SqContainsWrapper self, long arg0, long arg1) { + private int executeSqContains(long arg0, long arg1) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { Object jArg0 = NativeToPythonInternalNode.executeUncached(arg0, false); Object jArg1 = NativeToPythonInternalNode.executeUncached(arg1, false); - return CallSlotSqContainsNode.executeUncached(self.getSlot(), jArg0, jArg1) ? 1 : 0; + return CallSlotSqContainsNode.executeUncached(getSlot(), jArg0, jArg1) ? 1 : 0; } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "SqContainsWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "SqContainsWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return -1; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -491,24 +511,25 @@ public ObjobjargWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_I_PPP, HANDLE_OBJ_OBJ_ARG); } + @CApiUpcallTarget @SuppressWarnings("try") - private static int executeObjobjarg(ObjobjargWrapper self, long arg0, long arg1, long arg2) { + private int executeObjobjarg(long arg0, long arg1, long arg2) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { Object jArg0 = NativeToPythonInternalNode.executeUncached(arg0, false); Object jArg1 = NativeToPythonInternalNode.executeUncached(arg1, false); Object jArg2 = NativeToPythonInternalNode.executeUncached(arg2, false); - CallSlotMpAssSubscriptNode.executeUncached(self.getSlot(), jArg0, jArg1, jArg2); + CallSlotMpAssSubscriptNode.executeUncached(getSlot(), jArg0, jArg1, jArg2); return 0; } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "ObjobjargWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "ObjobjargWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return -1; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -523,24 +544,25 @@ public SetAttrWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_I_PPP, HANDLE_SET_ATTR); } + @CApiUpcallTarget @SuppressWarnings("try") - private static int executeSetAttr(SetAttrWrapper self, long arg0, long arg1, long arg2) { + private int executeSetAttr(long arg0, long arg1, long arg2) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { Object jArg0 = NativeToPythonInternalNode.executeUncached(arg0, false); Object jArg1 = NativeToPythonInternalNode.executeUncached(arg1, false); Object jArg2 = NativeToPythonInternalNode.executeUncached(arg2, false); - CallManagedSlotSetAttrNode.executeUncached(self.getSlot(), jArg0, jArg1, jArg2); + CallManagedSlotSetAttrNode.executeUncached(getSlot(), jArg0, jArg1, jArg2); return 0; } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "SetAttrWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "SetAttrWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return -1; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -555,24 +577,25 @@ public DescrSetFunctionWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_I_PPP, HANDLE_DESCR_SET_FUNCTION); } + @CApiUpcallTarget @SuppressWarnings("try") - private static int executeDescrSetFunction(DescrSetFunctionWrapper self, long arg0, long arg1, long arg2) { + private int executeDescrSetFunction(long arg0, long arg1, long arg2) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { Object jArg0 = NativeToPythonInternalNode.executeUncached(arg0, false); Object jArg1 = NativeToPythonInternalNode.executeUncached(arg1, false); Object jArg2 = NativeToPythonInternalNode.executeUncached(arg2, false); - CallSlotDescrSet.executeUncached(self.getSlot(), jArg0, jArg1, jArg2); + CallSlotDescrSet.executeUncached(getSlot(), jArg0, jArg1, jArg2); return 0; } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "DescrSetFunctionWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "DescrSetFunctionWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return -1; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -588,8 +611,9 @@ public InitWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_I_PPP, HANDLE_INIT); } + @CApiUpcallTarget @SuppressWarnings("try") - private static int executeInit(InitWrapper self, long arg0, long arg1, long arg2) { + private int executeInit(long arg0, long arg1, long arg2) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { @@ -600,16 +624,16 @@ private static int executeInit(InitWrapper self, long arg0, long arg1, long arg2 Object[] starArgsArray = ExecutePositionalStarargsNode.executeUncached(starArgs); PKeyword[] kwArgsArray = ExpandKeywordStarargsNode.executeUncached(kwArgs); - CallSlotTpInitNode.executeUncached(self.getSlot(), receiver, starArgsArray, kwArgsArray); + CallSlotTpInitNode.executeUncached(getSlot(), receiver, starArgsArray, kwArgsArray); return 0; } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "InitWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "InitWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return -1; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -625,8 +649,9 @@ public NewWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_P_PPP, HANDLE_NEW); } + @CApiUpcallTarget @SuppressWarnings("try") - private static long executeNew(NewWrapper self, long arg0, long arg1, long arg2) { + private long executeNew(long arg0, long arg1, long arg2) { try (var gil = GilNode.uncachedAcquire()) { try { // convert args @@ -642,10 +667,10 @@ private static long executeNew(NewWrapper self, long arg0, long arg1, long arg2) } PKeyword[] kwArgsArray = ExpandKeywordStarargsNode.executeUncached(kwArgs); - Object result = CallSlotTpNewNode.executeUncached(self.getSlot(), receiver, pArgs, kwArgsArray); + Object result = CallSlotTpNewNode.executeUncached(getSlot(), receiver, pArgs, kwArgsArray); return PythonToNativeNewRefNode.executeLongUncached(result); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "NewWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "NewWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); @@ -665,8 +690,9 @@ public CallWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_P_PPP, HANDLE_CALL); } + @CApiUpcallTarget @SuppressWarnings("try") - private static long executeCall(CallWrapper self, long arg0, long arg1, long arg2) { + private long executeCall(long arg0, long arg1, long arg2) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { @@ -677,16 +703,16 @@ private static long executeCall(CallWrapper self, long arg0, long arg1, long arg Object[] starArgsArray = ExecutePositionalStarargsNode.executeUncached(starArgs); PKeyword[] kwArgsArray = ExpandKeywordStarargsNode.executeUncached(kwArgs); - Object result = CallSlotTpCallNode.executeUncached(self.getSlot(), receiver, starArgsArray, kwArgsArray); + Object result = CallSlotTpCallNode.executeUncached(getSlot(), receiver, starArgsArray, kwArgsArray); return PythonToNativeNewRefNode.executeLongUncached(result); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "CallWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "CallWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return NULLPTR; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -702,8 +728,9 @@ public NbPowerWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_P_PPP, HANDLE_NB_POWER); } + @CApiUpcallTarget @SuppressWarnings("try") - private static long executeNbPower(NbPowerWrapper self, long arg0, long arg1, long arg2) { + private long executeNbPower(long arg0, long arg1, long arg2) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { @@ -715,16 +742,16 @@ private static long executeNbPower(NbPowerWrapper self, long arg0, long arg1, lo Object wType = GetClassNode.executeUncached(w); TpSlots wSlots = GetTpSlotsNode.executeUncached(wType); boolean sameTypes = IsSameTypeNode.executeUncached(vType, wType); - Object result = CallSlotNbPowerNode.executeUncached(self.getSlot(), v, vType, w, wSlots.nb_power(), wType, z, sameTypes); + Object result = CallSlotNbPowerNode.executeUncached(getSlot(), v, vType, w, wSlots.nb_power(), wType, z, sameTypes); return PythonToNativeNewRefNode.executeLongUncached(result); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "NbPowerWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "NbPowerWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return NULLPTR; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -740,8 +767,9 @@ public NbInPlacePowerWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_P_PPP, HANDLE_NB_IN_PLACE_POWER); } + @CApiUpcallTarget @SuppressWarnings("try") - private static long executeNbInPlacePower(NbInPlacePowerWrapper self, long arg0, long arg1, long arg2) { + private long executeNbInPlacePower(long arg0, long arg1, long arg2) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { @@ -749,16 +777,16 @@ private static long executeNbInPlacePower(NbInPlacePowerWrapper self, long arg0, Object v = NativeToPythonInternalNode.executeUncached(arg0, false); Object w = NativeToPythonInternalNode.executeUncached(arg1, false); Object z = NativeToPythonInternalNode.executeUncached(arg2, false); - Object result = CallSlotNbInPlacePowerNode.executeUncached(self.getSlot(), v, w, z); + Object result = CallSlotNbInPlacePowerNode.executeUncached(getSlot(), v, w, z); return PythonToNativeNewRefNode.executeLongUncached(result); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "NbInPlacePowerWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "NbInPlacePowerWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return NULLPTR; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -774,8 +802,9 @@ public RichcmpFunctionWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_P_PPI, HANDLE_RICHCMP_FUNCTION); } + @CApiUpcallTarget @SuppressWarnings("try") - private static long executeRichcmpFunction(RichcmpFunctionWrapper self, long arg0, long arg1, int arg2) { + private long executeRichcmpFunction(long arg0, long arg1, int arg2) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { @@ -783,16 +812,16 @@ private static long executeRichcmpFunction(RichcmpFunctionWrapper self, long arg Object jArg0 = NativeToPythonInternalNode.executeUncached(arg0, false); Object jArg1 = NativeToPythonInternalNode.executeUncached(arg1, false); RichCmpOp op = RichCmpOp.fromNative(arg2); - Object result = CallSlotRichCmpNode.executeUncached(self.getSlot(), jArg0, jArg1, op); + Object result = CallSlotRichCmpNode.executeUncached(getSlot(), jArg0, jArg1, op); return PythonToNativeNewRefNode.executeLongUncached(result); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "RichcmpFunctionWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "RichcmpFunctionWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return NULLPTR; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -808,23 +837,24 @@ public SsizeargfuncSlotWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_P_PL, HANDLE_SSIZEARGFUNC_SLOT); } + @CApiUpcallTarget @SuppressWarnings("try") - private static long executeSsizeargfuncSlot(SsizeargfuncSlotWrapper self, long arg0, long arg1) { + private long executeSsizeargfuncSlot(long arg0, long arg1) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { Object jArg0 = NativeToPythonInternalNode.executeUncached(arg0, false); int index = ssizeAsIntUncached(arg1); - Object result = CallSlotSizeArgFun.executeUncached(self.getSlot(), jArg0, index); + Object result = CallSlotSizeArgFun.executeUncached(getSlot(), jArg0, index); return PythonToNativeNewRefNode.executeLongUncached(result); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "SsizeargfuncWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "SsizeargfuncWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return NULLPTR; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -853,24 +883,25 @@ public SsizeobjargprocWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_I_PLP, HANDLE_SSIZEOBJARGPROC); } + @CApiUpcallTarget @SuppressWarnings("try") - private static int executeSsizeobjargproc(SsizeobjargprocWrapper self, long arg0, long arg1, long arg2) { + private int executeSsizeobjargproc(long arg0, long arg1, long arg2) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { Object jArg0 = NativeToPythonInternalNode.executeUncached(arg0, false); int key = ssizeAsIntUncached(arg1); Object jArg2 = NativeToPythonInternalNode.executeUncached(arg2, false); - CallSlotSqAssItemNode.executeUncached(self.getSlot(), jArg0, key, jArg2); + CallSlotSqAssItemNode.executeUncached(getSlot(), jArg0, key, jArg2); return 0; } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "SsizeobjargprocWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "SsizeobjargprocWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return -1; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -885,21 +916,22 @@ public LenfuncWrapper(TpSlotManaged managedSlot) { super(managedSlot, SIGNATURE_L_P, HANDLE_LENFUNC); } + @CApiUpcallTarget @SuppressWarnings("try") - private static long executeLenfunc(LenfuncWrapper self, long arg0) { + private long executeLenfunc(long arg0) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { Object jArg0 = NativeToPythonInternalNode.executeUncached(arg0, false); - return CallSlotLenNode.executeUncached(self.getSlot(), jArg0); + return CallSlotLenNode.executeUncached(getSlot(), jArg0); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "LenfuncWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "LenfuncWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return -1; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -915,21 +947,22 @@ public HashfuncWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_L_P, HANDLE_HASHFUNC); } + @CApiUpcallTarget @SuppressWarnings("try") - private static long executeHashfunc(HashfuncWrapper self, long arg0) { + private long executeHashfunc(long arg0) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { Object jArg0 = NativeToPythonInternalNode.executeUncached(arg0, false); - return CallSlotHashFunNode.executeUncached(self.getSlot(), jArg0); + return CallSlotHashFunNode.executeUncached(getSlot(), jArg0); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "HashfuncWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "HashfuncWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return -1; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } } @@ -944,8 +977,9 @@ public DescrGetFunctionWrapper(TpSlotManaged slot) { super(slot, SIGNATURE_P_PPP, HANDLE_DESCR_GET_FUNCTION); } + @CApiUpcallTarget @SuppressWarnings("try") - private static long executeDescrGetFunction(DescrGetFunctionWrapper self, long arg0, long arg1, long arg2) { + private long executeDescrGetFunction(long arg0, long arg1, long arg2) { try (var gil = GilNode.uncachedAcquire()) { CApiTiming.enter(); try { @@ -953,16 +987,16 @@ private static long executeDescrGetFunction(DescrGetFunctionWrapper self, long a Object receiver = NativeToPythonInternalNode.executeUncached(arg0, false); Object obj = NativeToPythonInternalNode.executeUncached(arg1, false); Object cls = NativeToPythonInternalNode.executeUncached(arg2, false); - Object result = CallSlotDescrGet.executeUncached(self.getSlot(), receiver, obj, cls); + Object result = CallSlotDescrGet.executeUncached(getSlot(), receiver, obj, cls); return PythonToNativeNewRefNode.executeLongUncached(result); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "DescrGetFunctionWrapper", self.getSlot()); + throw checkThrowableBeforeNative(t, "DescrGetFunctionWrapper", getSlot()); } } catch (PException e) { TransformExceptionToNativeNode.executeUncached(e.getEscapedException()); return NULLPTR; } finally { - CApiTiming.exit(self.timing); + CApiTiming.exit(timing); } }