diff options
| author | Damien George | 2015-11-27 17:09:11 +0000 |
|---|---|---|
| committer | Damien George | 2015-11-29 14:25:36 +0000 |
| commit | b8cfb0d7b2c91ea1e17f6caeabfc9cb23166cdc1 (patch) | |
| tree | d8fc58ac063c837b22b15f7a3967a09f06013054 /py/mpconfig.h | |
| parent | 999cedb90ff0827cdb9dfe0e4faa6ebc1739d271 (diff) | |
py: Add support for 64-bit NaN-boxing object model, on 32-bit machine.
To use, put the following in mpconfigport.h:
#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_D)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
typedef int64_t mp_int_t;
typedef uint64_t mp_uint_t;
#define UINT_FMT "%llu"
#define INT_FMT "%lld"
Currently does not work with native emitter enabled.
Diffstat (limited to 'py/mpconfig.h')
| -rw-r--r-- | py/mpconfig.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h index 01956f63f..1f01b3de5 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -76,6 +76,19 @@ #define MICROPY_OBJ_REPR_C (2) +// A MicroPython object is a 64-bit word having the following form (called R): +// - seeeeeee eeeeffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff 64-bit fp, e != 0x7ff +// - s1111111 11110000 00000000 00000000 00000000 00000000 00000000 00000000 +/- inf +// - 01111111 11111000 00000000 00000000 00000000 00000000 00000000 00000000 normalised nan +// - 01111111 11111101 00000000 00000000 iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int +// - 01111111 11111110 00000000 00000000 qqqqqqqq qqqqqqqq qqqqqqqq qqqqqqq1 str +// - 01111111 11111100 00000000 00000000 pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment) +// Stored as O = R + 0x8004000000000000, retrieved as R = O - 0x8004000000000000. +// This makes pointers have all zeros in the top 32 bits. +// Small-ints and strs have 1 as LSB to make sure they don't look like pointers +// to the garbage collector. +#define MICROPY_OBJ_REPR_D (3) + #ifndef MICROPY_OBJ_REPR #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A) #endif |
