diff options
author | alon@honor <none@none> | 2010-10-09 13:55:35 -0700 |
---|---|---|
committer | alon@honor <none@none> | 2010-10-09 13:55:35 -0700 |
commit | eec779fced0cb0e9df260768d90aa0832f7bef1b (patch) | |
tree | 6083c00699840a32f857335b852562d5e5c9a78e /src/analyzer.js | |
parent | b7a45a4236221343f96642499d1dfc84f327fb9b (diff) |
fix memory alignment/padding of structures | TESTS FIXED
Diffstat (limited to 'src/analyzer.js')
-rw-r--r-- | src/analyzer.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index 47c7281b..92aa0a8a 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -177,7 +177,7 @@ function analyzer(data) { var soFar = type.flatSize; var size; if (isNumberType(field) || isPointerType(field)) { - size = getNativeFieldSize(field); + size = getNativeFieldSize(field, true); // pack char; char; in structs, also char[X]s. } else if (isStructType(field)) { size = item.types[field].flatSize; } else { @@ -185,8 +185,9 @@ function analyzer(data) { } type.flatSize += size; sizes.push(size); - return soFar; + return Runtime.alignMemory(soFar, Math.min(QUANTUM_SIZE, size)); // if necessary, place this on aligned memory }); + type.flatSize = Runtime.alignMemory(type.flatSize); // padding at end if (dedup(sizes).length == 1) { type.flatFactor = sizes[0]; } |