Skip to content

Commit 5674cc4

Browse files
committed
Avoid to-address conversion for 'ob_refcnt'.
1 parent 5f08f44 commit 5674cc4

File tree

1 file changed

+5
-7
lines changed
  • graalpython/com.oracle.graal.python.cext/src

1 file changed

+5
-7
lines changed

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,12 @@ inline void* native_to_java(PyObject* obj) {
185185

186186
__attribute__((always_inline))
187187
inline void* native_type_to_java(PyTypeObject* type) {
188-
PyObject* obj = (PyObject*)type;
189-
void* refcnt = obj->ob_refcnt;
190-
if (!truffle_cannot_be_handle(refcnt)) {
191-
return resolve_handle(cache, refcnt);
192-
} else if (IS_POINTER(refcnt)) {
193-
return refcnt;
188+
if (IS_POINTER(((PyObject*)type)->ob_refcnt)) {
189+
return (void*)((PyObject*)type)->ob_refcnt;
190+
} else if (!truffle_cannot_be_handle(((PyObject*)type)->ob_refcnt)) {
191+
return resolve_handle(cache, ((PyObject*)type)->ob_refcnt);
194192
}
195-
return obj;
193+
return (void*)type;
196194
}
197195

198196
extern void* to_java(PyObject* obj);

0 commit comments

Comments
 (0)