diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-04-20 20:50:19 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-04-29 13:01:58 -0700 |
commit | d5afbea4576cae55facb921e2b88e56cc0ecbace (patch) | |
tree | fc83be620887389a81d7268332d091d5f4db2c52 | |
parent | 049753ab9202598e4c1287f7b16cb55d46a795c2 (diff) |
align i64s and doubles to 64-bit boundaries
-rw-r--r-- | src/runtime.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/runtime.js b/src/runtime.js index 5269301c..d0c22c6f 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -187,10 +187,10 @@ var Runtime = { var size, alignSize; if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) { size = Runtime.getNativeTypeSize(field); // pack char; char; in structs, also char[X]s. - alignSize = size; + alignSize = size; // we align i64s and doubles on 64-bit boundaries, unlike x86 } else if (Runtime.isStructType(field)) { size = Types.types[field].flatSize; - alignSize = Types.types[field].alignSize; + alignSize = Math.min(Types.types[field].alignSize, Runtime.QUANTUM_SIZE); } else if (field[0] == 'b') { // bN, large number field, like a [N x i8] size = field.substr(1)|0; @@ -198,7 +198,7 @@ var Runtime = { } else { throw 'Unclear type in struct: ' + field + ', in ' + type.name_ + ' :: ' + dump(Types.types[type.name_]); } - alignSize = type.packed ? 1 : Math.min(alignSize, Runtime.QUANTUM_SIZE); + if (type.packed) alignSize = 1; type.alignSize = Math.max(type.alignSize, alignSize); var curr = Runtime.alignMemory(type.flatSize, alignSize); // if necessary, place this on aligned memory type.flatSize = curr + size; |