@@ -198,25 +198,6 @@ static HPy ctx_ListNew_jni(HPyContext *ctx, HPy_ssize_t len) {
198
198
//*************************
199
199
// BOXING
200
200
201
- #define NAN_BOXING_BASE (0x0007000000000000llu)
202
- #define NAN_BOXING_MASK (0xFFFF000000000000llu)
203
- #define NAN_BOXING_INT (0x0001000000000000llu)
204
- #define NAN_BOXING_INT_MASK (0x00000000FFFFFFFFllu)
205
- #define NAN_BOXING_MAX_HANDLE (0x000000007FFFFFFFllu)
206
- #define IMMUTABLE_HANDLES (0x0000000000000100llu)
207
-
208
- static bool isBoxedDouble (uint64_t value ) {
209
- return value >= NAN_BOXING_BASE ;
210
- }
211
-
212
- static bool isBoxedHandle (uint64_t value ) {
213
- return value <= NAN_BOXING_MAX_HANDLE ;
214
- }
215
-
216
- static bool isBoxedInt (uint64_t value ) {
217
- return (value & NAN_BOXING_MASK ) == NAN_BOXING_INT ;
218
- }
219
-
220
201
static double unboxDouble (uint64_t value ) {
221
202
uint64_t doubleBits = value - NAN_BOXING_BASE ;
222
203
return * ((double * ) & doubleBits );
@@ -228,32 +209,6 @@ static uint64_t boxDouble(double value) {
228
209
return doubleBits + NAN_BOXING_BASE ;
229
210
}
230
211
231
- static uint64_t unboxHandle (uint64_t value ) {
232
- return value ;
233
- }
234
-
235
- static uint64_t boxHandle (uint64_t handle ) {
236
- return handle ;
237
- }
238
-
239
- static int32_t unboxInt (uint64_t value ) {
240
- return (int32_t ) (value - NAN_BOXING_INT );
241
- }
242
-
243
- static uint64_t boxInt (int32_t value ) {
244
- return (value & NAN_BOXING_INT_MASK ) + NAN_BOXING_INT ;
245
- }
246
-
247
- static inline uint64_t toBits (HPy ptr ) {
248
- /* return * ((uint64_t*) &ptr._i); */
249
- return (uint64_t ) (ptr ._i );
250
- }
251
-
252
- static inline HPy toPtr (uint64_t ptr ) {
253
- /* return * ((void**) &ptr); */
254
- return (HPy ) { (HPy_ssize_t ) ptr };
255
- }
256
-
257
212
//*************************
258
213
// direct fast paths that handle certain calls on the native side:
259
214
@@ -325,7 +280,7 @@ static HPy augment_LongFromLong(HPyContext *ctx, long l) {
325
280
326
281
#define MAX_UNCLOSED_HANDLES 32
327
282
static int32_t unclosedHandleTop = 0 ;
328
- static uint64_t unclosedHandles [MAX_UNCLOSED_HANDLES ] = { 0 } ;
283
+ static HPy unclosedHandles [MAX_UNCLOSED_HANDLES ];
329
284
330
285
static void augment_Close (HPyContext * ctx , HPy h ) {
331
286
uint64_t bits = toBits (h );
@@ -336,9 +291,9 @@ static void augment_Close(HPyContext *ctx, HPy h) {
336
291
return ;
337
292
}
338
293
if (unclosedHandleTop < MAX_UNCLOSED_HANDLES ) {
339
- unclosedHandles [unclosedHandleTop ++ ] = bits ;
294
+ unclosedHandles [unclosedHandleTop ++ ] = h ;
340
295
} else {
341
- DO_UPCALL_VOID ( CONTEXT_INSTANCE ( ctx ), BulkClose , unclosedHandles , unclosedHandleTop );
296
+ upcallBulkClose ( ctx , unclosedHandles , unclosedHandleTop );
342
297
memset (unclosedHandles , 0 , sizeof (uint64_t ) * unclosedHandleTop );
343
298
unclosedHandleTop = 0 ;
344
299
}
@@ -454,6 +409,9 @@ static HPy augment_TupleFromArray(HPyContext *ctx, HPy *items, HPy_ssize_t nitem
454
409
return upcallTupleFromArray (ctx , items , nitems , JNI_FALSE );
455
410
}
456
411
412
+ _HPy_HIDDEN void upcallBulkClose (HPyContext * ctx , HPy * items , HPy_ssize_t nitems ) {
413
+ DO_UPCALL_VOID (CONTEXT_INSTANCE (ctx ), BulkClose , items , nitems );
414
+ }
457
415
458
416
void initDirectFastPaths (HPyContext * context ) {
459
417
LOG ("%p" , context );
0 commit comments