diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-12-06 16:07:54 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-12-06 16:07:54 -0800 |
commit | 4e71da9599137a28676cd7635d57e7ad67660f35 (patch) | |
tree | 4b52f010f247d6a92806059394cabc43bccf7a15 /src/parseTools.js | |
parent | 7a01a170be7b483a1b27010a84a4971939714899 (diff) |
DOUBLE_MODE=1 option to carefuly load and store doubles even in unaligned ta2 mode. fixes test_unaligned in ta2 and default
Diffstat (limited to 'src/parseTools.js')
-rw-r--r-- | src/parseTools.js | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index 3eaf3577..86bd6bc1 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -889,7 +889,7 @@ function getHeapOffset(offset, type) { } // See makeSetValue -function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align) { +function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSafe) { if (isStructType(type)) { var typeData = Types.types[type]; var ret = []; @@ -899,6 +899,12 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align) { return '{ ' + ret.join(', ') + ' }'; } + if (DOUBLE_MODE == 1 && USE_TYPED_ARRAYS == 2 && type == 'double') { + return '(tempDoubleF32[0]=' + makeGetValue(ptr, pos, 'float', noNeedFirst, unsigned, ignore) + ',' + + 'tempDoubleF32[1]=' + makeGetValue(ptr, getFastValue(pos, '+', Runtime.getNativeTypeSize('float')), 'float', noNeedFirst, unsigned, ignore) + ',' + + 'tempDoubleF64[0])'; + } + if (EMULATE_UNALIGNED_ACCESSES && USE_TYPED_ARRAYS == 2 && align && isIntImplemented(type)) { // TODO: support unaligned doubles and floats // Alignment is important here. May need to split this up var bytes = Runtime.getNativeTypeSize(type); @@ -928,7 +934,7 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align) { } var offset = calcFastOffset(ptr, pos, noNeedFirst); - if (SAFE_HEAP) { + if (SAFE_HEAP && !noSafe) { if (type !== 'null' && type[0] !== '#') type = '"' + safeQuote(type) + '"'; if (type[0] === '#') type = type.substr(1); return 'SAFE_HEAP_LOAD(' + offset + ', ' + type + ', ' + (!!unsigned+0) + ', ' + ((!checkSafeHeap() || ignore)|0) + ')'; @@ -960,7 +966,7 @@ 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) { +function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, noSafe) { if (isStructType(type)) { var typeData = Types.types[type]; var ret = []; @@ -975,6 +981,12 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align) { return ret.join('; '); } + if (DOUBLE_MODE == 1 && USE_TYPED_ARRAYS == 2 && type == 'double') { + return '(tempDoubleF64[0]=' + value + ',' + + makeSetValue(ptr, pos, 'tempDoubleF32[0]', 'float', noNeedFirst, ignore, align/2) + ',' + + makeSetValue(ptr, getFastValue(pos, '+', Runtime.getNativeTypeSize('i32')), 'tempDoubleF32[1]', 'float', noNeedFirst, ignore, align/2) + ')'; + } + if (EMULATE_UNALIGNED_ACCESSES && USE_TYPED_ARRAYS == 2 && align && isIntImplemented(type)) { // TODO: support unaligned doubles and floats // Alignment is important here. May need to split this up var bytes = Runtime.getNativeTypeSize(type); @@ -1003,7 +1015,7 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align) { value = indexizeFunctions(value, type); var offset = calcFastOffset(ptr, pos, noNeedFirst); - if (SAFE_HEAP) { + if (SAFE_HEAP && !noSafe) { if (type !== 'null' && type[0] !== '#') type = '"' + safeQuote(type) + '"'; if (type[0] === '#') type = type.substr(1); return 'SAFE_HEAP_STORE(' + offset + ', ' + value + ', ' + type + ', ' + ((!checkSafeHeap() || ignore)|0) + ')'; |