diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-01-17 16:12:09 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-01-17 16:12:09 -0800 |
commit | dd7771e94e0e80c4232c39140a0263a18e0bfa86 (patch) | |
tree | 2df84dae1d163e0e8e571adc01b7680991e12036 /src | |
parent | af52dc5060efa8121130be7976ac919deceab358 (diff) |
handle unsigned reads in safe heap
Diffstat (limited to 'src')
-rw-r--r-- | src/parseTools.js | 2 | ||||
-rw-r--r-- | src/preamble.js | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index a564f2e3..1c70a018 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1328,7 +1328,7 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSa if (printType !== 'null' && printType[0] !== '#') printType = '"' + safeQuote(printType) + '"'; if (printType[0] === '#') printType = printType.substr(1); if (ASM_JS) { - if (!ignore) return asmCoercion('SAFE_HEAP_LOAD(' + asmCoercion(offset, 'i32') + ', ' + Runtime.getNativeTypeSize(type) + ', ' + ((type in Runtime.FLOAT_TYPES)|0) + ')', type); + if (!ignore) return asmCoercion('SAFE_HEAP_LOAD(' + asmCoercion(offset, 'i32') + ', ' + Runtime.getNativeTypeSize(type) + ', ' + ((type in Runtime.FLOAT_TYPES)|0) + ', ' + (!!unsigned+0) + ')', type); // else fall through } else { return asmCoercion('SAFE_HEAP_LOAD(' + offset + ', ' + (ASM_JS ? 0 : printType) + ', ' + (!!unsigned+0) + ', ' + ((!checkSafeHeap() || ignore)|0) + ')', type); diff --git a/src/preamble.js b/src/preamble.js index d70ef4b1..d415b87e 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -189,13 +189,16 @@ function SAFE_HEAP_STORE(dest, value, bytes, isFloat) { setValue(dest, value, getSafeHeapType(bytes, isFloat), 1); } -function SAFE_HEAP_LOAD(dest, bytes, isFloat) { +function SAFE_HEAP_LOAD(dest, bytes, isFloat, unsigned) { #if SAFE_HEAP_LOG - Module.print('SAFE_HEAP load: ' + [dest, bytes, isFloat]); + Module.print('SAFE_HEAP load: ' + [dest, bytes, isFloat, unsigned]); #endif assert(dest > 0, 'segmentation fault'); assert(dest % bytes === 0); - return getValue(dest, getSafeHeapType(bytes, isFloat), 1); + var type = getSafeHeapType(bytes, isFloat); + var ret = getValue(dest, type, 1); + if (unsigned) ret = unSign(ret, parseInt(type.substr(1)), 1); + return ret; } #endif |