diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/parseTools.js | 22 | ||||
-rw-r--r-- | src/runtime.js | 2 | ||||
-rw-r--r-- | src/settings.js | 2 |
3 files changed, 18 insertions, 8 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index bace60db..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(' + offset + ', ' + 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(' + offset + ', ' + value + ', ' + 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); } 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__'; }, diff --git a/src/settings.js b/src/settings.js index 6ffa8c33..26b649e0 100644 --- a/src/settings.js +++ b/src/settings.js @@ -132,6 +132,8 @@ var SAFE_HEAP = 0; // Check each write to the heap, for example, this will give // that 3 is the option you usually want here. var SAFE_HEAP_LOG = 0; // Log out all SAFE_HEAP operations +var ASM_HEAP_LOG = 0; // Simple heap logging, like SAFE_HEAP_LOG but cheaper, and in asm.js + var LABEL_DEBUG = 0; // 1: Print out functions as we enter them // 2: Also print out each label as we enter it var LABEL_FUNCTION_FILTERS = []; // Filters for function label debug. |