projects
/
ghc-hetmet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a196ef8
)
newPinnedByteArray#: align the result to 16-bytes (part of #2917)
author
Simon Marlow
<marlowsd@gmail.com>
Thu, 19 Feb 2009 10:32:45 +0000
(10:32 +0000)
committer
Simon Marlow
<marlowsd@gmail.com>
Thu, 19 Feb 2009 10:32:45 +0000
(10:32 +0000)
rts/PrimOps.cmm
patch
|
blob
|
history
diff --git
a/rts/PrimOps.cmm
b/rts/PrimOps.cmm
index
cd9a5bf
..
a6e221b
100644
(file)
--- a/
rts/PrimOps.cmm
+++ b/
rts/PrimOps.cmm
@@
-91,17
+91,24
@@
newPinnedByteArrayzh_fast
n = R1;
payload_words = ROUNDUP_BYTES_TO_WDS(n);
n = R1;
payload_words = ROUNDUP_BYTES_TO_WDS(n);
- // We want a 16-byte aligned array. allocatePinned() gives us
+ // We want an 8-byte aligned array. allocatePinned() gives us
// 8-byte aligned memory by default, but we want to align the
// *goods* inside the ArrWords object, so we have to check the
// size of the ArrWords header and adjust our size accordingly.
// 8-byte aligned memory by default, but we want to align the
// *goods* inside the ArrWords object, so we have to check the
// size of the ArrWords header and adjust our size accordingly.
- words = payload_words + ((SIZEOF_StgArrWords + 15) & ~15);
+ words = BYTES_TO_WDS(SIZEOF_StgArrWords) + payload_words;
+ if ((SIZEOF_StgArrWords & 7) != 0) {
+ words = words + 1;
+ }
("ptr" p) = foreign "C" allocatePinned(words) [];
TICK_ALLOC_PRIM(SIZEOF_StgArrWords,WDS(payload_words),0);
("ptr" p) = foreign "C" allocatePinned(words) [];
TICK_ALLOC_PRIM(SIZEOF_StgArrWords,WDS(payload_words),0);
- // Push the pointer forward so that the goods fall on a 16-byte boundary.
- p = p + ((p + SIZEOF_StgArrWords) & 15);
+ // Again, if the ArrWords header isn't a multiple of 8 bytes, we
+ // have to push the object forward one word so that the goods
+ // fall on an 8-byte boundary.
+ if ((SIZEOF_StgArrWords & 7) != 0) {
+ p = p + WDS(1);
+ }
SET_HDR(p, stg_ARR_WORDS_info, W_[CCCS]);
StgArrWords_words(p) = payload_words;
SET_HDR(p, stg_ARR_WORDS_info, W_[CCCS]);
StgArrWords_words(p) = payload_words;