diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/zisp/value/array.zig | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/zisp/value/array.zig b/src/zisp/value/array.zig index 5d326a1..34e75b9 100644 --- a/src/zisp/value/array.zig +++ b/src/zisp/value/array.zig @@ -50,6 +50,13 @@ const Value = value.Value; /// Other remaining bits provide information about element type and size. pub const ArrayPtr = *align(@alignOf(value.Zptr)) ArrayHeader; +// Important: We may use a hack where lists, residing in their own heap region, +// can be turned into value arrays by transforming their first element into an +// ArrayHeader. However, it might simplify the GC algorithm if the entirety of +// that heap region can be treated as Value slots. If we ensure that ArrayHead +// never looks like a Value with a pointer payload, this will be safe; as such, +// we ensure that it has some of the "exponent" bits unset, making it always +// look like a regular Double value. This is what "_DONTUSE" is for. pub const ArrayHeader = packed struct(u64) { len_or_ptr: u48, is_slice: bool = false, @@ -57,27 +64,31 @@ pub const ArrayHeader = packed struct(u64) { type: ArrayType, info: packed union { int: packed struct(u12) { - size: u10, - signed: bool, endian: Endian = .native, + _DONTUSE: bool = false, + size: u9, + signed: bool, }, flt: packed struct(u12) { - size: u10, - _: bool, endian: Endian = .native, + _DONTUSE: bool = false + size: u10, }, val: packed struct(u12) { - weak: bool, - _: u11, + _unused1: bool = false, + _DONTUSE: bool = false, + _unused2: u9 = 0, + weak: bool = false, }, str: packed struct(u12) { - encoding: enum(u11) { + endian: Endian = .native, + _DONTUSE: bool = false, + encoding: enum(u10) { utf8, utf16, utf24, utf32, } = .utf8, - endian: Endian = .native, }, }, |
