diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2014-08-16 09:49:30 +0200 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2014-08-16 16:01:35 +0200 |
commit | 246436f13739593d2a211ceb830393338118ca4d (patch) | |
tree | 90630d9ece70e613ae9f9aa6ccd4b95fa69545bf /includes/Cmm.h | |
parent | d39c434a9518b7376857be88503055ecb7d0fe1f (diff) | |
download | haskell-246436f13739593d2a211ceb830393338118ca4d.tar.gz |
Implement {resize,shrink}MutableByteArray# primops
The two new primops with the type-signatures
resizeMutableByteArray# :: MutableByteArray# s -> Int#
-> State# s -> (# State# s, MutableByteArray# s #)
shrinkMutableByteArray# :: MutableByteArray# s -> Int#
-> State# s -> State# s
allow to resize MutableByteArray#s in-place (when possible), and are useful
for algorithms where memory is temporarily over-allocated. The motivating
use-case is for implementing integer backends, where the final target size of
the result is either N or N+1, and only known after the operation has been
performed.
A future commit will implement a stateful variant of the
`sizeofMutableByteArray#` operation (see #9447 for details), since now the
size of a `MutableByteArray#` may change over its lifetime (i.e before
it gets frozen or GCed).
Test Plan: ./validate --slow
Reviewers: ezyang, austin, simonmar
Reviewed By: austin, simonmar
Differential Revision: https://phabricator.haskell.org/D133
Diffstat (limited to 'includes/Cmm.h')
-rw-r--r-- | includes/Cmm.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/includes/Cmm.h b/includes/Cmm.h index 24bdda30c5..e62e96fcc0 100644 --- a/includes/Cmm.h +++ b/includes/Cmm.h @@ -600,8 +600,11 @@ #if defined(PROFILING) || (!defined(THREADED_RTS) && defined(DEBUG)) #define OVERWRITING_CLOSURE(c) foreign "C" overwritingClosure(c "ptr") +#define OVERWRITING_CLOSURE_OFS(c,n) \ + foreign "C" overwritingClosureOfs(c "ptr", n) #else #define OVERWRITING_CLOSURE(c) /* nothing */ +#define OVERWRITING_CLOSURE_OFS(c,n) /* nothing */ #endif #ifdef THREADED_RTS |