Skip to content

Commit b96d948

Browse files
committed
Use new Sulong intrinsic 'truffle_cannot_be_handle'.
1 parent 455bb78 commit b96d948

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

graalpython/com.oracle.graal.python.cext/include/truffle.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ void *truffle_managed_from_handle(void *nativeHandle);
5252
bool truffle_is_handle_to_managed(void *nativeHandle);
5353
void *truffle_assign_managed(void *dst, void *managed);
5454
void *truffle_deref_handle_for_managed(void *managed);
55+
bool truffle_cannot_be_handle(void *nativeHandle);
5556

5657
/*
5758
* All function below here are deprecated and will be removed in a future release.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,12 @@ PyObject* to_sulong(void *o) {
215215
/** to be used from Java code only; reads native 'ob_type' field */
216216
void* get_ob_type(PyObject* obj) {
217217
PyTypeObject* type = obj->ob_type;
218-
if (truffle_is_handle_to_managed(type)) {
218+
if (!truffle_cannot_be_handle(type)) {
219219
return resolve_handle(cache, (uint64_t)type);
220220
} else {
221221
// we have stored a handle to the Java class in ob_refcnt
222222
void* handle = (void*)((PyObject*)type)->ob_refcnt;
223-
if (truffle_is_handle_to_managed(handle)) {
223+
if (!truffle_cannot_be_handle(handle)) {
224224
return resolve_handle(cache, (uint64_t)handle);
225225
} else {
226226
// assume handle is a TruffleObject
@@ -248,15 +248,15 @@ uint64_t PyTruffle_Wchar_Size() {
248248
}
249249

250250
void* PyObjectHandle_ForJavaObject(void* cobj, unsigned long flags) {
251-
if (truffle_is_handle_to_managed(cobj)) {
251+
if (truffle_cannot_be_handle(cobj)) {
252252
return truffle_deref_handle_for_managed(cobj);
253253
}
254254
return cobj;
255255
}
256256

257257
/** to be used from Java code only; only creates the deref handle */
258258
void* PyObjectHandle_ForJavaType(void* ptype) {
259-
if (truffle_is_handle_to_managed(ptype)) {
259+
if (truffle_cannot_be_handle(ptype)) {
260260
return truffle_deref_handle_for_managed(ptype);
261261
}
262262
return ptype;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ inline void* native_to_java(PyObject* obj) {
166166
return Py_None;
167167
} else if (polyglot_is_string(obj)) {
168168
return obj;
169-
} else if (truffle_is_handle_to_managed(obj)) {
169+
} else if (!truffle_cannot_be_handle(obj)) {
170170
return resolve_handle(cache, (uint64_t)obj);
171171
} else {
172172
void* refcnt = obj->ob_refcnt;
173-
if (truffle_is_handle_to_managed(refcnt)) {
173+
if (!truffle_cannot_be_handle(refcnt)) {
174174
return resolve_handle(cache, refcnt);
175175
} else if (IS_POINTER(refcnt)) {
176176
return refcnt;

mx.graalpython/suite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
},
2626
{
2727
"name": "sulong",
28-
"version": "588b2880ed6a7575179cc771776f4a87f16783e3",
28+
"version": "a8a599d132146bb0f87a2b95572db7d76b641b88",
2929
"subdir": True,
3030
"urls": [
3131
{"url": "https://github.com/oracle/graal", "kind": "git"},
3232
]
3333
},
3434
{
3535
"name": "regex",
36-
"version": "588b2880ed6a7575179cc771776f4a87f16783e3",
36+
"version": "a8a599d132146bb0f87a2b95572db7d76b641b88",
3737
"subdir": True,
3838
"urls": [
3939
{"url": "https://github.com/oracle/graal", "kind": "git"},

0 commit comments

Comments
 (0)