Store primitive GC arrays as raw byte buffers - #9051
Conversation
|
This PR ends up causing quite a bit of churn, but it makes implementing multibyte load/stores from numeric arrays pretty easy compared to my original PR. This PR should also use less memory for numeric arrays and be faster for most operations on them. In some follow up PRs, we could also move strings into the vectors to make them more efficient. I also explored a few other ways of implementing this:
If anyone thinks we should just land my other PR or has other thoughts on how to do this let me know. |
| isNull() || isData() || | ||
| (type.isRef() && (type.getHeapType().isMaybeShared(HeapType::ext) || | ||
| type.getHeapType().isMaybeShared(HeapType::string) || | ||
| type.getHeapType().isMaybeShared(HeapType::any) || |
There was a problem hiding this comment.
I'm confused. Does this PR change how strings are implemented, and not just numeric arrays? If not, why is this code changing?
There was a problem hiding this comment.
I started with changing strings in this PR, but it was getting big so I moved it to another branch. Looks like I didn't get all of that code. Will remove...
|
|
||
| static void writeField(void* p, const Field& field, Literal value); | ||
| static Literal | ||
| readField(const void* p, const Field& field, bool signed_ = false); |
There was a problem hiding this comment.
What is p in these? Perhaps add a comment?
|
|
||
| uint8_t buf[16]; | ||
| value.getBits(buf); | ||
| memcpy(p, buf, field.getByteSize()); |
There was a problem hiding this comment.
Perhaps assert that the byte size is less than 16 from two lines ago? Some day we may get larger types...
GCData previously represented all allocations using a vector of Literals. Storing numeric array elements this way introduces unnecessary memory overhead and prevents efficient byte-level operations. Represent primitive numeric GC arrays using a raw byte buffer in GCData while preserving Literals storage for reference arrays and structs.
131d1a1 to
dd3fbea
Compare
GCData previously represented all allocations using a vector of Literals. Storing numeric array elements this way introduces unnecessary memory overhead and prevents efficient byte-level operations.
Represent primitive numeric GC arrays using a raw byte buffer in GCData while preserving Literals storage for reference arrays and structs.