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. |
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
| if (srcVal + lengthVal > srcData->getNumElements()) { | ||
| trap("oob"); | ||
| } | ||
| if (destData->isRawBytes() && srcData->isRawBytes()) { |
There was a problem hiding this comment.
Is this an optimization, or would the getElement/setElement path below not do the right thing?
There was a problem hiding this comment.
This is an optimization. I added a comment. Alternatively, I can remove and do optimizations in a follow up.
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.