Skip to content

Commit 354b57b

Browse files
committed
fix inconsistent usages of ArgDescriptor.ConstCharPtrAsTruffleString
1 parent d352616 commit 354b57b

File tree

10 files changed

+53
-88
lines changed

10 files changed

+53
-88
lines changed

graalpython/com.oracle.graal.python.cext/src/capi.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ typedef struct {
299299
BUILTIN(PyTruffleLong_FromString, PyObject*, const char*, int, int) \
300300
BUILTIN(PyTruffleLong_One, PyObject*) \
301301
BUILTIN(PyTruffleLong_Zero, PyObject*) \
302-
BUILTIN(PyTruffleModule_AddFunctionToModule, int, void*, PyObject*, const char*, void*, int, int, void*) \
302+
BUILTIN(PyTruffleModule_AddFunctionToModule, int, void*, PyObject*, const char*, void*, int, int, const char*) \
303303
BUILTIN(PyTruffleNumber_BinOp, PyObject*, PyObject*, PyObject*, int) \
304304
BUILTIN(PyTruffleNumber_InPlaceBinOp, PyObject*, PyObject*, PyObject*, int) \
305305
BUILTIN(PyTruffleNumber_UnaryOp, PyObject*, PyObject*, int) \
@@ -312,10 +312,10 @@ typedef struct {
312312
BUILTIN(PyTruffleStructSequence_InitType2, int, PyTypeObject*, void*, void*, int) \
313313
BUILTIN(PyTruffleStructSequence_NewType, PyTypeObject*, const char*, const char*, void*, void*, int) \
314314
BUILTIN(PyTruffleToCharPointer, void*, PyObject*) \
315-
BUILTIN(PyTruffleType_AddFunctionToType, int, void*, PyTypeObject*, PyObject*, const char*, void*, int, int, void*) \
316-
BUILTIN(PyTruffleType_AddGetSet, int, PyTypeObject*, PyObject*, const char*, void*, void*, void*, void*) \
317-
BUILTIN(PyTruffleType_AddMember, int, PyTypeObject*, PyObject*, const char*, int, Py_ssize_t, int, void*) \
318-
BUILTIN(PyTruffleType_AddSlot, int, PyTypeObject*, PyObject*, const char*, void*, int, int, void*) \
315+
BUILTIN(PyTruffleType_AddFunctionToType, int, void*, PyTypeObject*, PyObject*, const char*, void*, int, int, const char*) \
316+
BUILTIN(PyTruffleType_AddGetSet, int, PyTypeObject*, PyObject*, const char*, void*, void*, const char*, void*) \
317+
BUILTIN(PyTruffleType_AddMember, int, PyTypeObject*, PyObject*, const char*, int, Py_ssize_t, int, const char*) \
318+
BUILTIN(PyTruffleType_AddSlot, int, PyTypeObject*, PyObject*, const char*, void*, int, int, const char*) \
319319
BUILTIN(PyTruffleUnicode_Decode, PyObject*, PyObject*, const char*, const char*) \
320320
BUILTIN(PyTruffleUnicode_DecodeUTF8Stateful, PyObject*, void*, const char*, int) \
321321
BUILTIN(PyTruffleUnicode_FromUCS, PyObject*, void*, Py_ssize_t, int) \

graalpython/com.oracle.graal.python.cext/src/methodobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -65,7 +65,7 @@ PyObject* PyCMethod_New(PyMethodDef *ml, PyObject *self, PyObject *module, PyTyp
6565
self,
6666
module,
6767
cls,
68-
PyMethodDef_ml_doc(ml));
68+
truffleString(PyMethodDef_ml_doc(ml)));
6969
}
7070

7171
PyCFunction PyCFunction_GetFunction(PyObject *func) {

graalpython/com.oracle.graal.python.cext/src/moduleobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ int PyModule_AddFunctions(PyObject* mod, PyMethodDef* methods) {
3232
function_pointer_to_java(def->ml_meth),
3333
def->ml_flags,
3434
get_method_flags_wrapper(def->ml_flags),
35-
def->ml_doc);
35+
truffleString(def->ml_doc));
3636
}
3737
return 0;
3838
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBuiltinRegistry.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ private PythonCextBuiltinRegistry() {
260260
public static final CApiBuiltinExecutable PyTruffleLong_FromString = new CApiBuiltinExecutable("PyTruffleLong_FromString", CApiCallPath.Ignored, ArgDescriptor.PyObjectTransfer, new ArgDescriptor[]{ArgDescriptor.ConstCharPtrAsTruffleString, ArgDescriptor.Int, ArgDescriptor.Int}, 199);
261261
public static final CApiBuiltinExecutable PyTruffleLong_One = new CApiBuiltinExecutable("PyTruffleLong_One", CApiCallPath.Ignored, ArgDescriptor.PyObjectTransfer, new ArgDescriptor[]{}, 200);
262262
public static final CApiBuiltinExecutable PyTruffleLong_Zero = new CApiBuiltinExecutable("PyTruffleLong_Zero", CApiCallPath.Ignored, ArgDescriptor.PyObjectTransfer, new ArgDescriptor[]{}, 201);
263-
public static final CApiBuiltinExecutable PyTruffleModule_AddFunctionToModule = new CApiBuiltinExecutable("PyTruffleModule_AddFunctionToModule", CApiCallPath.Ignored, ArgDescriptor.Int, new ArgDescriptor[]{ArgDescriptor.Pointer, ArgDescriptor.PyObject, ArgDescriptor.ConstCharPtrAsTruffleString, ArgDescriptor.Pointer, ArgDescriptor.Int, ArgDescriptor.Int, ArgDescriptor.Pointer}, 202);
263+
public static final CApiBuiltinExecutable PyTruffleModule_AddFunctionToModule = new CApiBuiltinExecutable("PyTruffleModule_AddFunctionToModule", CApiCallPath.Ignored, ArgDescriptor.Int, new ArgDescriptor[]{ArgDescriptor.Pointer, ArgDescriptor.PyObject, ArgDescriptor.ConstCharPtrAsTruffleString, ArgDescriptor.Pointer, ArgDescriptor.Int, ArgDescriptor.Int, ArgDescriptor.ConstCharPtrAsTruffleString}, 202);
264264
public static final CApiBuiltinExecutable PyTruffleNumber_BinOp = new CApiBuiltinExecutable("PyTruffleNumber_BinOp", CApiCallPath.Ignored, ArgDescriptor.PyObjectTransfer, new ArgDescriptor[]{ArgDescriptor.PyObject, ArgDescriptor.PyObject, ArgDescriptor.Int}, 203);
265265
public static final CApiBuiltinExecutable PyTruffleNumber_InPlaceBinOp = new CApiBuiltinExecutable("PyTruffleNumber_InPlaceBinOp", CApiCallPath.Ignored, ArgDescriptor.PyObjectTransfer, new ArgDescriptor[]{ArgDescriptor.PyObject, ArgDescriptor.PyObject, ArgDescriptor.Int}, 204);
266266
public static final CApiBuiltinExecutable PyTruffleNumber_UnaryOp = new CApiBuiltinExecutable("PyTruffleNumber_UnaryOp", CApiCallPath.Ignored, ArgDescriptor.PyObjectTransfer, new ArgDescriptor[]{ArgDescriptor.PyObject, ArgDescriptor.Int}, 205);
@@ -273,10 +273,10 @@ private PythonCextBuiltinRegistry() {
273273
public static final CApiBuiltinExecutable PyTruffleStructSequence_InitType2 = new CApiBuiltinExecutable("PyTruffleStructSequence_InitType2", CApiCallPath.Ignored, ArgDescriptor.Int, new ArgDescriptor[]{ArgDescriptor.PyTypeObject, ArgDescriptor.Pointer, ArgDescriptor.Pointer, ArgDescriptor.Int}, 212);
274274
public static final CApiBuiltinExecutable PyTruffleStructSequence_NewType = new CApiBuiltinExecutable("PyTruffleStructSequence_NewType", CApiCallPath.Ignored, ArgDescriptor.PyTypeObjectTransfer, new ArgDescriptor[]{ArgDescriptor.ConstCharPtrAsTruffleString, ArgDescriptor.ConstCharPtrAsTruffleString, ArgDescriptor.Pointer, ArgDescriptor.Pointer, ArgDescriptor.Int}, 213);
275275
public static final CApiBuiltinExecutable PyTruffleToCharPointer = new CApiBuiltinExecutable("PyTruffleToCharPointer", CApiCallPath.Ignored, ArgDescriptor.Pointer, new ArgDescriptor[]{ArgDescriptor.PyObject}, 214);
276-
public static final CApiBuiltinExecutable PyTruffleType_AddFunctionToType = new CApiBuiltinExecutable("PyTruffleType_AddFunctionToType", CApiCallPath.Ignored, ArgDescriptor.Int, new ArgDescriptor[]{ArgDescriptor.Pointer, ArgDescriptor.PyTypeObject, ArgDescriptor.PyObject, ArgDescriptor.ConstCharPtrAsTruffleString, ArgDescriptor.Pointer, ArgDescriptor.Int, ArgDescriptor.Int, ArgDescriptor.Pointer}, 215);
277-
public static final CApiBuiltinExecutable PyTruffleType_AddGetSet = new CApiBuiltinExecutable("PyTruffleType_AddGetSet", CApiCallPath.Ignored, ArgDescriptor.Int, new ArgDescriptor[]{ArgDescriptor.PyTypeObject, ArgDescriptor.PyObject, ArgDescriptor.ConstCharPtrAsTruffleString, ArgDescriptor.Pointer, ArgDescriptor.Pointer, ArgDescriptor.Pointer, ArgDescriptor.Pointer}, 216);
278-
public static final CApiBuiltinExecutable PyTruffleType_AddMember = new CApiBuiltinExecutable("PyTruffleType_AddMember", CApiCallPath.Ignored, ArgDescriptor.Int, new ArgDescriptor[]{ArgDescriptor.PyTypeObject, ArgDescriptor.PyObject, ArgDescriptor.ConstCharPtrAsTruffleString, ArgDescriptor.Int, ArgDescriptor.Py_ssize_t, ArgDescriptor.Int, ArgDescriptor.Pointer}, 217);
279-
public static final CApiBuiltinExecutable PyTruffleType_AddSlot = new CApiBuiltinExecutable("PyTruffleType_AddSlot", CApiCallPath.Ignored, ArgDescriptor.Int, new ArgDescriptor[]{ArgDescriptor.PyTypeObject, ArgDescriptor.PyObject, ArgDescriptor.ConstCharPtrAsTruffleString, ArgDescriptor.Pointer, ArgDescriptor.Int, ArgDescriptor.Int, ArgDescriptor.Pointer}, 218);
276+
public static final CApiBuiltinExecutable PyTruffleType_AddFunctionToType = new CApiBuiltinExecutable("PyTruffleType_AddFunctionToType", CApiCallPath.Ignored, ArgDescriptor.Int, new ArgDescriptor[]{ArgDescriptor.Pointer, ArgDescriptor.PyTypeObject, ArgDescriptor.PyObject, ArgDescriptor.ConstCharPtrAsTruffleString, ArgDescriptor.Pointer, ArgDescriptor.Int, ArgDescriptor.Int, ArgDescriptor.ConstCharPtrAsTruffleString}, 215);
277+
public static final CApiBuiltinExecutable PyTruffleType_AddGetSet = new CApiBuiltinExecutable("PyTruffleType_AddGetSet", CApiCallPath.Ignored, ArgDescriptor.Int, new ArgDescriptor[]{ArgDescriptor.PyTypeObject, ArgDescriptor.PyObject, ArgDescriptor.ConstCharPtrAsTruffleString, ArgDescriptor.Pointer, ArgDescriptor.Pointer, ArgDescriptor.ConstCharPtrAsTruffleString, ArgDescriptor.Pointer}, 216);
278+
public static final CApiBuiltinExecutable PyTruffleType_AddMember = new CApiBuiltinExecutable("PyTruffleType_AddMember", CApiCallPath.Ignored, ArgDescriptor.Int, new ArgDescriptor[]{ArgDescriptor.PyTypeObject, ArgDescriptor.PyObject, ArgDescriptor.ConstCharPtrAsTruffleString, ArgDescriptor.Int, ArgDescriptor.Py_ssize_t, ArgDescriptor.Int, ArgDescriptor.ConstCharPtrAsTruffleString}, 217);
279+
public static final CApiBuiltinExecutable PyTruffleType_AddSlot = new CApiBuiltinExecutable("PyTruffleType_AddSlot", CApiCallPath.Ignored, ArgDescriptor.Int, new ArgDescriptor[]{ArgDescriptor.PyTypeObject, ArgDescriptor.PyObject, ArgDescriptor.ConstCharPtrAsTruffleString, ArgDescriptor.Pointer, ArgDescriptor.Int, ArgDescriptor.Int, ArgDescriptor.ConstCharPtrAsTruffleString}, 218);
280280
public static final CApiBuiltinExecutable PyTruffleUnicode_Decode = new CApiBuiltinExecutable("PyTruffleUnicode_Decode", CApiCallPath.Ignored, ArgDescriptor.PyObjectTransfer, new ArgDescriptor[]{ArgDescriptor.PyObject, ArgDescriptor.ConstCharPtrAsTruffleString, ArgDescriptor.ConstCharPtrAsTruffleString}, 219);
281281
public static final CApiBuiltinExecutable PyTruffleUnicode_DecodeUTF8Stateful = new CApiBuiltinExecutable("PyTruffleUnicode_DecodeUTF8Stateful", CApiCallPath.Ignored, ArgDescriptor.PyObjectTransfer, new ArgDescriptor[]{ArgDescriptor.Pointer, ArgDescriptor.ConstCharPtrAsTruffleString, ArgDescriptor.Int}, 220);
282282
public static final CApiBuiltinExecutable PyTruffleUnicode_FromUCS = new CApiBuiltinExecutable("PyTruffleUnicode_FromUCS", CApiCallPath.Ignored, ArgDescriptor.PyObjectTransfer, new ArgDescriptor[]{ArgDescriptor.Pointer, ArgDescriptor.Py_ssize_t, ArgDescriptor.Int}, 221);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextDescrBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ abstract static class PyTruffleDescr_NewGetSet extends CApi6BuiltinNode {
7979
@Specialization
8080
Object doNativeCallable(TruffleString name, Object cls, Object getter, Object setter, Object doc, Object closure,
8181
@Cached CreateGetSetNode createGetSetNode) {
82-
return createGetSetNode.execute(name, cls, getter, setter, doc, closure, getLanguage(), factory());
82+
return createGetSetNode.execute(name, cls, getter, setter, doc, closure);
8383
}
8484
}
8585

@@ -89,7 +89,7 @@ abstract static class PyTruffleDescr_NewClassMethod extends CApi7BuiltinNode {
8989
@Specialization
9090
Object doNativeCallable(Object methodDefPtr, TruffleString name, Object doc, int flags, Object wrapper, Object methObj, Object type,
9191
@Cached NewClassMethodNode newClassMethodNode) {
92-
Object func = newClassMethodNode.execute(methodDefPtr, name, methObj, flags, wrapper, type, doc, factory());
92+
Object func = newClassMethodNode.execute(methodDefPtr, name, methObj, flags, wrapper, type, doc);
9393
if (!isClassOrStaticMethod(flags)) {
9494
/*
9595
* NewClassMethodNode only wraps method with METH_CLASS and METH_STATIC set but we

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextMethodBuiltins.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBuiltin;
5757
import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CreateFunctionNode;
5858
import com.oracle.graal.python.builtins.objects.PNone;
59-
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.CharPtrToJavaObjectNode;
6059
import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction;
6160
import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod;
6261
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
@@ -79,26 +78,22 @@ public final class PythonCextMethodBuiltins {
7978

8079
abstract static class CFunctionNewExMethodNode extends Node {
8180

82-
abstract Object execute(Object methodDefPtr, TruffleString name, Object methObj, Object flags, Object wrapper, Object self, Object module, Object cls, Object doc,
83-
PythonObjectFactory factory);
81+
abstract Object execute(Object methodDefPtr, TruffleString name, Object methObj, Object flags, Object wrapper, Object self, Object module, Object cls, Object doc);
8482

85-
final Object execute(Object methodDefPtr, TruffleString name, Object methObj, Object flags, Object wrapper, Object self, Object module, Object doc,
86-
PythonObjectFactory factory) {
87-
return execute(methodDefPtr, name, methObj, flags, wrapper, self, module, PNone.NO_VALUE, doc, factory);
83+
final Object execute(Object methodDefPtr, TruffleString name, Object methObj, Object flags, Object wrapper, Object self, Object module, Object doc) {
84+
return execute(methodDefPtr, name, methObj, flags, wrapper, self, module, PNone.NO_VALUE, doc);
8885
}
8986

9087
@Specialization
9188
static Object doNativeCallable(Object methodDefPtr, TruffleString name, Object methObj, Object flags, Object wrapper, Object self, Object module, Object cls, Object doc,
92-
PythonObjectFactory factory,
89+
@Cached PythonObjectFactory factory,
9390
@Cached CreateFunctionNode createFunctionNode,
94-
@CachedLibrary(limit = "1") DynamicObjectLibrary dylib,
95-
@Cached CharPtrToJavaObjectNode charPtrToJavaObjectNode) {
91+
@CachedLibrary(limit = "1") DynamicObjectLibrary dylib) {
9692
Object f = createFunctionNode.execute(name, methObj, wrapper, PNone.NO_VALUE, flags, factory);
9793
assert f instanceof PBuiltinFunction;
9894
PBuiltinFunction func = (PBuiltinFunction) f;
9995
dylib.put(func.getStorage(), T___NAME__, name);
100-
Object strDoc = charPtrToJavaObjectNode.execute(doc);
101-
dylib.put(func.getStorage(), T___DOC__, strDoc);
96+
dylib.put(func.getStorage(), T___DOC__, doc);
10297
PBuiltinMethod method;
10398
if (cls != PNone.NO_VALUE) {
10499
method = factory.createBuiltinMethod(self, func, cls);
@@ -115,9 +110,9 @@ static Object doNativeCallable(Object methodDefPtr, TruffleString name, Object m
115110
abstract static class PyTruffleCMethod_NewEx extends CApi9BuiltinNode {
116111

117112
@Specialization
118-
Object doNativeCallable(Object methodDefPtr, TruffleString name, Object methObj, int flags, int wrapper, Object self, Object module, Object cls, Object doc,
113+
static Object doNativeCallable(Object methodDefPtr, TruffleString name, Object methObj, int flags, int wrapper, Object self, Object module, Object cls, Object doc,
119114
@Cached CFunctionNewExMethodNode cFunctionNewExMethodNode) {
120-
return cFunctionNewExMethodNode.execute(methodDefPtr, name, methObj, flags, wrapper, self, module, cls, doc, factory());
115+
return cFunctionNewExMethodNode.execute(methodDefPtr, name, methObj, flags, wrapper, self, module, cls, doc);
121116
}
122117
}
123118
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextModuleBuiltins.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,17 @@ protected boolean isModuleSubtype(Object obj, GetClassNode getClassNode, IsSubty
204204
}
205205
}
206206

207-
@CApiBuiltin(ret = Int, args = {Pointer, PyObject, ConstCharPtrAsTruffleString, Pointer, Int, Int, Pointer}, call = Ignored)
207+
@CApiBuiltin(ret = Int, args = {Pointer, PyObject, ConstCharPtrAsTruffleString, Pointer, Int, Int, ConstCharPtrAsTruffleString}, call = Ignored)
208208
abstract static class PyTruffleModule_AddFunctionToModule extends CApi7BuiltinNode {
209209

210210
@Specialization
211-
Object moduleFunction(Object methodDefPtr, PythonModule mod, TruffleString name, Object cfunc, int flags, int wrapper, Object doc,
211+
static Object moduleFunction(Object methodDefPtr, PythonModule mod, TruffleString name, Object cfunc, int flags, int wrapper, Object doc,
212212
@Cached ObjectBuiltins.SetattrNode setattrNode,
213213
@CachedLibrary(limit = "1") DynamicObjectLibrary dylib,
214214
@Cached CFunctionNewExMethodNode cFunctionNewExMethodNode) {
215215
Object modName = dylib.getOrDefault(mod.getStorage(), T___NAME__, null);
216216
assert modName != null : "module name is missing!";
217-
Object func = cFunctionNewExMethodNode.execute(methodDefPtr, name, cfunc, flags, wrapper, mod, modName, doc, factory());
217+
Object func = cFunctionNewExMethodNode.execute(methodDefPtr, name, cfunc, flags, wrapper, mod, modName, doc);
218218
setattrNode.execute(null, mod, name, func);
219219
return 0;
220220
}

0 commit comments

Comments
 (0)