diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-01-28 13:59:39 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-01-28 13:59:39 -0800 |
commit | 496dd28973e6156773975fd6ad093cab271f46bb (patch) | |
tree | adc0b8b761e97008123a3832d9b99a803eee150c /src/parseTools.js | |
parent | 1712044102bdd9d48ed4b699d5cba6368a3beb16 (diff) |
improve asm safe heap support and add ASM_HEAP_LOG
Diffstat (limited to 'src/parseTools.js')
-rw-r--r-- | src/parseTools.js | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index 994e391b..f5e2f33f 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1079,6 +1079,8 @@ function makeSetTempDouble(i, type, value) { return makeGetTempDouble(i, type, true) + '=' + asmEnsureFloat(value, type); } +var asmPrintCounter = 0; + // See makeSetValue function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSafe, forceAsm) { if (UNALIGNED_MEMORY) align = 1; @@ -1129,14 +1131,19 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSa var offset = calcFastOffset(ptr, pos, noNeedFirst); if (SAFE_HEAP && !noSafe) { - if (type !== 'null' && type[0] !== '#') type = '"' + safeQuote(type) + '"'; - if (type[0] === '#') type = type.substr(1); - return 'SAFE_HEAP_LOAD(' + asmCoercion(offset, 'i32') + ', ' + (ASM_JS ? 0 : type) + ', ' + (!!unsigned+0) + ', ' + ((!checkSafeHeap() || ignore)|0) + ')'; + var printType = type; + if (printType !== 'null' && printType[0] !== '#') printType = '"' + safeQuote(printType) + '"'; + if (printType[0] === '#') printType = printType.substr(1); + return asmCoercion('SAFE_HEAP_LOAD(' + asmCoercion(offset, 'i32') + ', ' + (ASM_JS ? 0 : printType) + ', ' + (!!unsigned+0) + ', ' + ((!checkSafeHeap() || ignore)|0) + ')', type); } else { var ret = makeGetSlabs(ptr, type, false, unsigned)[0] + '[' + getHeapOffset(offset, type, forceAsm) + ']'; - if (ASM_JS && phase == 'funcs') { + if (ASM_JS && (phase == 'funcs' || forceAsm)) { ret = asmCoercion(ret, type); } + if (ASM_HEAP_LOG) { + ret = makeInlineCalculation('(asmPrint' + (type in Runtime.FLOAT_TYPES ? 'Float' : 'Int') + '(' + (asmPrintCounter++) + ',' + asmCoercion('VALUE', type) + '), VALUE)', ret, + 'temp' + (type in Runtime.FLOAT_TYPES ? 'Double' : 'Int')); + } return ret; } } @@ -1232,9 +1239,10 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, noSafe, value = indexizeFunctions(value, type); var offset = calcFastOffset(ptr, pos, noNeedFirst); if (SAFE_HEAP && !noSafe) { - if (type !== 'null' && type[0] !== '#') type = '"' + safeQuote(type) + '"'; - if (type[0] === '#') type = type.substr(1); - return 'SAFE_HEAP_STORE(' + asmCoercion(offset, 'i32') + ', ' + asmCoercion(value, type) + ', ' + (ASM_JS ? 0 : type) + ', ' + ((!checkSafeHeap() || ignore)|0) + ')'; + var printType = type; + if (printType !== 'null' && printType[0] !== '#') printType = '"' + safeQuote(printType) + '"'; + if (printType[0] === '#') printType = printType.substr(1); + return 'SAFE_HEAP_STORE(' + asmCoercion(offset, 'i32') + ', ' + asmCoercion(value, type) + ', ' + (ASM_JS ? 0 : printType) + ', ' + ((!checkSafeHeap() || ignore)|0) + ')'; } else { return makeGetSlabs(ptr, type, true).map(function(slab) { return slab + '[' + getHeapOffset(offset, type, forceAsm) + ']=' + value }).join(sep); } |