diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-02-08 12:07:17 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-02-08 12:07:17 -0800 |
commit | ef59283debcb71ddadf5d9e9c2444d463f165557 (patch) | |
tree | 4d45bcf00b6a0620e3c3aa77adb03eff54dd4bd9 /src/parseTools.js | |
parent | cd7d64a1945a7309804008feead7ebe4acb5a722 (diff) |
refactor legalizer code, and handle stores of <32 bits but not i8 or i16, properly
Diffstat (limited to 'src/parseTools.js')
-rw-r--r-- | src/parseTools.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index f2f72fa3..29b8bdbf 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -966,8 +966,11 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, noSafe, makeSetValue(ptr, getFastValue(pos, '+', Runtime.getNativeTypeSize('i32')), 'tempDoubleI32[1]', 'i32', noNeedFirst, ignore, align, noSafe, ',') + ')'; } + if (!align && isIntImplemented(type) && !isPowerOfTwo(getBits(type))) { + align = 1; // we need to split this up, as if alignment were 1, this is an unnatural type like i24 + } if (USE_TYPED_ARRAYS == 2 && align) { - // Alignment is important here. May need to split this up + // Alignment is important here, or we need to split this up for other reasons. var bytes = Runtime.getNativeTypeSize(type); if (bytes > align) { var ret = ''; @@ -977,14 +980,13 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, noSafe, ret += 'tempBigInt=' + value + sep; ret += makeSetValue(ptr, pos, 'tempBigInt&0xffff', 'i16', noNeedFirst, ignore, 2) + sep; ret += makeSetValue(ptr, getFastValue(pos, '+', 2), 'tempBigInt>>16', 'i16', noNeedFirst, ignore, 2); - } else if (bytes <= 4) { + } else if (bytes != 8) { ret += 'tempBigInt=' + value + sep; for (var i = 0; i < bytes; i++) { ret += makeSetValue(ptr, getFastValue(pos, '+', i), 'tempBigInt&0xff', 'i8', noNeedFirst, ignore, 1); if (i < bytes-1) ret += sep + 'tempBigInt>>=8' + sep; } - } else { - assert(bytes == 8); + } else { // bytes == 8, specific optimization ret += 'tempPair=' + ensureI64_1(value) + sep; ret += makeSetValue(ptr, pos, 'tempPair[0]', 'i32', noNeedFirst, ignore, align) + sep; ret += makeSetValue(ptr, getFastValue(pos, '+', Runtime.getNativeTypeSize('i32')), 'tempPair[1]', 'i32', noNeedFirst, ignore, align); |