diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-01-28 11:15:12 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-01-28 11:15:12 -0800 |
commit | 19acb40b4c25ad93056e88b276d9d04079e28b1e (patch) | |
tree | d80c1fa29bde5324ec98e32f09b644ad13833436 /src | |
parent | 4e659b53221f744fcd27d2f049b205e97f9ed120 (diff) |
make safe heap work in asm
Diffstat (limited to 'src')
-rw-r--r-- | src/parseTools.js | 4 | ||||
-rw-r--r-- | src/runtime.js | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index bace60db..994e391b 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1131,7 +1131,7 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSa 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) + ')'; + return 'SAFE_HEAP_LOAD(' + asmCoercion(offset, 'i32') + ', ' + (ASM_JS ? 0 : type) + ', ' + (!!unsigned+0) + ', ' + ((!checkSafeHeap() || ignore)|0) + ')'; } else { var ret = makeGetSlabs(ptr, type, false, unsigned)[0] + '[' + getHeapOffset(offset, type, forceAsm) + ']'; if (ASM_JS && phase == 'funcs') { @@ -1234,7 +1234,7 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, noSafe, 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) + ')'; + return 'SAFE_HEAP_STORE(' + asmCoercion(offset, 'i32') + ', ' + asmCoercion(value, type) + ', ' + (ASM_JS ? 0 : type) + ', ' + ((!checkSafeHeap() || ignore)|0) + ')'; } else { return makeGetSlabs(ptr, type, true).map(function(slab) { return slab + '[' + getHeapOffset(offset, type, forceAsm) + ']=' + value }).join(sep); } diff --git a/src/runtime.js b/src/runtime.js index 43bd7de1..5fce4651 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -55,7 +55,7 @@ var RuntimeGenerator = { if (initial === 0 && SKIP_STACK_IN_SMALL && !force) return ''; var ret = ''; if (SAFE_HEAP) { - ret += 'for (var i = __stackBase__; i < STACKTOP; i++) SAFE_HEAP_CLEAR(i);'; + ret += 'var i = __stackBase__; while ((i|0) < (STACKTOP|0)) { SAFE_HEAP_CLEAR(i|0); i = (i+1)|0 }'; } return ret += 'STACKTOP = __stackBase__'; }, |