@@ -42,22 +42,20 @@ public final class ValueWrapperManager {
42
42
43
43
static final long UNSET_HANDLE = -2L ;
44
44
45
- /* These constants are taken from ruby.h, and are based on us not tagging doubles. */
45
+ /* These constants are taken from lib/cext/include/ ruby/internal/special_consts.h with USE_FLONUM=false */
46
46
47
- public static final int FALSE_HANDLE = 0b000;
48
- public static final int TRUE_HANDLE = 0b010;
49
- public static final int NIL_HANDLE = 0b100;
50
- public static final int UNDEF_HANDLE = 0b110;
47
+ public static final int FALSE_HANDLE = 0b0000;
48
+ public static final int TRUE_HANDLE = 0b0110;
49
+ public static final int NIL_HANDLE = 0b0010;
50
+ public static final int UNDEF_HANDLE = 0b1010;
51
+ public static final long IMMEDIATE_MASK = 0b0011;
51
52
52
53
public static final long LONG_TAG = 1 ;
53
54
public static final long OBJECT_TAG = 0 ;
54
55
55
56
public static final long MIN_FIXNUM_VALUE = -(1L << 62 );
56
57
public static final long MAX_FIXNUM_VALUE = (1L << 62 ) - 1 ;
57
58
58
- public static final long TAG_MASK = 0b111;
59
- public static final long TAG_BITS = 3 ;
60
-
61
59
public final ValueWrapper trueWrapper = new ValueWrapper (true , TRUE_HANDLE , null );
62
60
public final ValueWrapper falseWrapper = new ValueWrapper (false , FALSE_HANDLE , null );
63
61
public final ValueWrapper undefWrapper = new ValueWrapper (NotProvided .INSTANCE , UNDEF_HANDLE , null );
@@ -177,9 +175,10 @@ public long totalHandleAllocations() {
177
175
return counter .get ();
178
176
}
179
177
178
+ private static final long ADDRESS_ALIGN_BITS = 3 ;
180
179
private static final int BLOCK_BITS = 15 ;
181
- private static final int BLOCK_SIZE = 1 << (BLOCK_BITS - TAG_BITS );
182
- private static final int BLOCK_BYTE_SIZE = BLOCK_SIZE << TAG_BITS ;
180
+ private static final int BLOCK_SIZE = 1 << (BLOCK_BITS - ADDRESS_ALIGN_BITS );
181
+ private static final int BLOCK_BYTE_SIZE = BLOCK_SIZE << ADDRESS_ALIGN_BITS ;
183
182
private static final long BLOCK_MASK = -1L << BLOCK_BITS ;
184
183
private static final long OFFSET_MASK = ~BLOCK_MASK ;
185
184
public static final long ALLOCATION_BASE = 0x0badL << 48 ;
@@ -245,7 +244,7 @@ public int getIndex() {
245
244
}
246
245
247
246
public ValueWrapper getWrapper (long handle ) {
248
- int offset = (int ) (handle & OFFSET_MASK ) >> TAG_BITS ;
247
+ int offset = (int ) (handle & OFFSET_MASK ) >> ADDRESS_ALIGN_BITS ;
249
248
return wrappers [offset ].get ();
250
249
}
251
250
@@ -371,7 +370,7 @@ public static boolean isTaggedLong(long handle) {
371
370
}
372
371
373
372
public static boolean isTaggedObject (long handle ) {
374
- return handle != FALSE_HANDLE && (handle & TAG_MASK ) == OBJECT_TAG ;
373
+ return handle != FALSE_HANDLE && (handle & IMMEDIATE_MASK ) == OBJECT_TAG ;
375
374
}
376
375
377
376
public static boolean isMallocAligned (long handle ) {
0 commit comments