diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-10-16 18:40:27 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-10-17 12:44:21 -0700 |
commit | ee500a3d942327563451bfc81dee0a3044a3cb7e (patch) | |
tree | d5674ccc751f4e004b15b025929a88e6e6e005d7 /src/parseTools.js | |
parent | a2b4acbd95c1f307d0d51bfd0134f6a88a087c46 (diff) |
UNALIGNED_MEMORY option to emulate unaligned reads/writes all the time, to support some nonportable code
Diffstat (limited to 'src/parseTools.js')
-rw-r--r-- | src/parseTools.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index 80ba269b..8e919d15 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -905,6 +905,7 @@ function getHeapOffset(offset, type) { // See makeSetValue function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSafe) { + if (UNALIGNED_MEMORY) align = 1; if (isStructType(type)) { var typeData = Types.types[type]; var ret = []; @@ -930,7 +931,7 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSa // Special case that we can optimize ret += makeGetValue(ptr, pos, 'i16', noNeedFirst, 2, ignore) + '+' + '(' + makeGetValue(ptr, getFastValue(pos, '+', 2), 'i16', noNeedFirst, 2, ignore) + '<<16)'; - } else if (bytes <= 4) { + } else { // XXX we cannot truly handle > 4... ret = ''; for (var i = 0; i < bytes; i++) { ret += '(' + makeGetValue(ptr, getFastValue(pos, '+', i), 'i8', noNeedFirst, 1, ignore) + (i > 0 ? '<<' + (8*i) : '') + ')'; @@ -983,7 +984,8 @@ function indexizeFunctions(value, type) { //! 'null' means, in the context of SAFE_HEAP, that we should accept all types; //! which means we should write to all slabs, ignore type differences if any on reads, etc. //! @param noNeedFirst Whether to ignore the offset in the pointer itself. -function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, noSafe, sep) { +function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, noSafe, sep, forcedAlign) { + if (UNALIGNED_MEMORY && !forcedAlign) align = 1; sep = sep || ';'; if (isStructType(type)) { var typeData = Types.types[type]; @@ -1026,7 +1028,7 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, noSafe, } } } else { - ret += makeSetValue('tempDoublePtr', 0, value, type, noNeedFirst, ignore, 8) + sep; + ret += makeSetValue('tempDoublePtr', 0, value, type, noNeedFirst, ignore, 8, null, null, true) + sep; ret += makeCopyValues(getFastValue(ptr, '+', pos), 'tempDoublePtr', Runtime.getNativeTypeSize(type), type, null, align, sep); } return ret; |