|
51 | 51 | import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyTypeObject;
|
52 | 52 | import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.Py_ssize_t;
|
53 | 53 | import static com.oracle.graal.python.builtins.objects.cext.common.CExtContext.METH_CLASS;
|
| 54 | +import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_name; |
54 | 55 | import static com.oracle.graal.python.nodes.HiddenAttr.METHOD_DEF_PTR;
|
55 | 56 | import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___DOC__;
|
56 | 57 | import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__;
|
57 | 58 | import static com.oracle.graal.python.util.PythonUtils.EMPTY_OBJECT_ARRAY;
|
58 |
| -import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; |
59 | 59 |
|
60 | 60 | import com.oracle.graal.python.PythonLanguage;
|
61 | 61 | import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApi7BuiltinNode;
|
|
119 | 119 | import com.oracle.truffle.api.dsl.ImportStatic;
|
120 | 120 | import com.oracle.truffle.api.dsl.Specialization;
|
121 | 121 | import com.oracle.truffle.api.interop.InteropLibrary;
|
122 |
| -import com.oracle.truffle.api.interop.UnsupportedMessageException; |
123 | 122 | import com.oracle.truffle.api.library.CachedLibrary;
|
124 | 123 | import com.oracle.truffle.api.nodes.Node;
|
125 | 124 | import com.oracle.truffle.api.nodes.RootNode;
|
@@ -247,27 +246,16 @@ static Object doIt(PythonAbstractNativeObject clazz,
|
247 | 246 | }
|
248 | 247 | }
|
249 | 248 |
|
250 |
| - @CApiBuiltin(ret = Int, args = {Pointer, Pointer}, call = Ignored) |
251 |
| - abstract static class PyTruffle_Trace_Type extends CApiBinaryBuiltinNode { |
| 249 | + @CApiBuiltin(ret = Int, args = {Pointer}, call = Ignored) |
| 250 | + abstract static class PyTruffle_Trace_Type extends CApiUnaryBuiltinNode { |
252 | 251 | private static final TruffleLogger LOGGER = CApiContext.getLogger(PyTruffle_Trace_Type.class);
|
253 | 252 |
|
254 |
| - @Specialization(limit = "3") |
255 |
| - int trace(Object ptr, Object classNameObj, |
256 |
| - @CachedLibrary("ptr") InteropLibrary ptrLib, |
257 |
| - @CachedLibrary("classNameObj") InteropLibrary nameLib, |
258 |
| - @Cached TruffleString.SwitchEncodingNode switchEncodingNode) { |
259 |
| - final TruffleString className; |
260 |
| - if (nameLib.isString(classNameObj)) { |
261 |
| - try { |
262 |
| - className = switchEncodingNode.execute(nameLib.asTruffleString(classNameObj), TS_ENCODING); |
263 |
| - } catch (UnsupportedMessageException e) { |
264 |
| - throw CompilerDirectives.shouldNotReachHere(e); |
265 |
| - } |
266 |
| - } else { |
267 |
| - className = null; |
268 |
| - } |
269 |
| - Object primitivePtr = CApiContext.asPointer(ptr, ptrLib); |
270 |
| - LOGGER.fine(() -> PythonUtils.formatJString("Initializing native type %s (ptr = %s)", className, CApiContext.asHex(primitivePtr))); |
| 253 | + @Specialization |
| 254 | + @TruffleBoundary |
| 255 | + int trace(Object ptr) { |
| 256 | + LOGGER.fine(() -> PythonUtils.formatJString("Initializing native type %s (ptr = %s)", |
| 257 | + CStructAccess.ReadCharPtrNode.getUncached().read(ptr, PyTypeObject__tp_name), |
| 258 | + CApiContext.asHex(CApiContext.asPointer(ptr, InteropLibrary.getUncached())))); |
271 | 259 | return 0;
|
272 | 260 | }
|
273 | 261 | }
|
|
0 commit comments