Skip to content
Permalink
Browse files
Fixed NaN boxing for 64-bit configrations on platforms that use full …
…48-bit usermode pointers

Definition of boxed pointer is following:
`111111111111TTTT TTPPPPPPPPPPPPPP PPPPPPPPPPPPPPPP PPPPPPPPPPPPPPPP`

Previously, only the last 32-bit were set, and remaining 14 bits were zeroed when setting `ttt`.
  • Loading branch information
dabroz committed Nov 21, 2016
1 parent d86f5d2 commit 8cdaf1ed35e808f73fe06c84998ffa59d414f8cc
Showing 1 changed file with 7 additions and 1 deletion.
@@ -60,6 +60,12 @@ typedef struct mrb_value {
#define mrb_fixnum(o) (o).value.i
#define mrb_symbol(o) (o).value.sym

#ifdef MRB_64BIT
#define BOXNAN_SHIFT_LONG_POINTER(v) (((uintptr_t)(v)>>34)&0x3fff)
#else
#define BOXNAN_SHIFT_LONG_POINTER(v) 0
#endif

#define BOXNAN_SET_VALUE(o, tt, attr, v) do {\
switch (tt) {\
case MRB_TT_FALSE:\
@@ -69,7 +75,7 @@ typedef struct mrb_value {
case MRB_TT_SYMBOL: (o).attr = (v); break;\
default: (o).value.i = 0; (o).value.p = (void*)((uintptr_t)(o).value.p | (((uintptr_t)(v))>>2)); break;\
}\
(o).value.ttt = (0xfff00000|(((tt)+1)<<14));\
(o).value.ttt = (0xfff00000|(((tt)+1)<<14)|BOXNAN_SHIFT_LONG_POINTER(v));\
} while (0)

#define SET_FLOAT_VALUE(mrb,r,v) do { \

0 comments on commit 8cdaf1e

Please sign in to comment.