Add support for resizing `MutableByteArray#`s
This is motivated by #9281 (closed) which changes how memory is allocated, and gives rise to the need to be able to efficiently shrink or grow MutableByteArray#
s before they're frozen into ByteArray#
while retaining their original byte content to avoid a major bottle-neck.
This ticket is for tracking/documenting all changes related to this new facility.
Here's the current road-map:
- Implement
shrinkMutableByteArray# :: MutableByteArray# s -> Int# -> State# s -> State# s
resizeMutableByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, MutableByteArray# s #)
(see D133)
- As suggested by Johan,
getSizeofMutableByteArray# :: MutableByteArray# s -> State# s -> (# State# s Int# #)
This is similar in spirit to numCapabilities
and getNumCapabilities
.
Add a deprecate pragma (or equivalent) for sizeofMutableByteArray#
.
Add a note to sizeofMutableByteArray#
stating that it's unsafe in the presence of calls to resize-operations on the same MBA.
- Submit patches to upstream libraries replacing calls to
sizeofMutableByteArray#
withgetSizeofMutableByteArray#
- Investigate how to provide in-place (zero-copy) growing of MBAs (step 1. only implements in-place shrinking).
Trac metadata
Trac field | Value |
---|---|
Version | 7.8.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | D133 |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |