@@ -53,10 +53,7 @@ uint64_t (*PY_TRUFFLE_CEXT_LANDING_L)(void* name, ...);
53
53
double (* PY_TRUFFLE_CEXT_LANDING_D )(void * name , ...);
54
54
void * (* PY_TRUFFLE_CEXT_LANDING_PTR )(void * name , ...);
55
55
56
- typedef void * (* cache_t )(uint64_t );
57
- static cache_t cache ;
58
-
59
- #define resolve_handle (__cache__ , __addr__ ) (__cache__)(__addr__)
56
+ cache_t cache ;
60
57
61
58
__attribute__((constructor (__COUNTER__ )))
62
59
static void initialize_upcall_functions () {
@@ -198,28 +195,6 @@ static void initialize_capi() {
198
195
initialize_bufferprocs ();
199
196
}
200
197
201
- // Heuristic to test if some value is a pointer object
202
- // TODO we need a reliable solution for that
203
- #define IS_POINTER (__val__ ) (polyglot_is_value(__val__) && !polyglot_fits_in_i64(__val__))
204
-
205
- MUST_INLINE
206
- void * native_to_java (PyObject * obj ) {
207
- if (obj == NULL ) {
208
- return Py_NoValue ;
209
- } else if (obj == Py_None ) {
210
- return Py_None ;
211
- } else if (polyglot_is_string (obj )) {
212
- return obj ;
213
- } else if (truffle_is_handle_to_managed (obj )) {
214
- return resolve_handle (cache , (uint64_t )obj );
215
- } else if (truffle_is_handle_to_managed (obj -> ob_refcnt )) {
216
- return truffle_managed_from_handle (obj -> ob_refcnt );
217
- } else if (IS_POINTER (obj -> ob_refcnt )) {
218
- return obj -> ob_refcnt ;
219
- }
220
- return obj ;
221
- }
222
-
223
198
void * native_to_java_exported (PyObject * obj ) {
224
199
return native_to_java (obj );
225
200
}
@@ -273,15 +248,15 @@ uint64_t PyTruffle_Wchar_Size() {
273
248
}
274
249
275
250
void * PyObjectHandle_ForJavaObject (void * cobj , unsigned long flags ) {
276
- if (! truffle_is_handle_to_managed (cobj )) {
251
+ if (truffle_is_handle_to_managed (cobj )) {
277
252
return truffle_deref_handle_for_managed (cobj );
278
253
}
279
254
return cobj ;
280
255
}
281
256
282
257
/** to be used from Java code only; only creates the deref handle */
283
258
void * PyObjectHandle_ForJavaType (void * ptype ) {
284
- if (! truffle_is_handle_to_managed (ptype )) {
259
+ if (truffle_is_handle_to_managed (ptype )) {
285
260
return truffle_deref_handle_for_managed (ptype );
286
261
}
287
262
return ptype ;
0 commit comments