diff options
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r-- | tools/js-optimizer.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 82942ce2..4192ddd1 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -3227,6 +3227,7 @@ function outline(ast) { if (asmData.splitCounter === asmData.maxOutlinings) return []; if (!extraInfo.allowCostlyOutlines) var originalStats = copy(stats); var code = stats.slice(start, end+1); + var originalCodeSize = measureSize(code); var funcSize = measureSize(func); var outlineIndex = asmData.splitCounter++; var newIdent = func[1] + '$' + outlineIndex; @@ -3239,7 +3240,6 @@ function outline(ast) { owned[v] = 1; } }); - printErr('attempting outline ' + [func[1], newIdent, 'overhead:', setSize(setSub(codeInfo.writes, owned)), setSize(setSub(codeInfo.reads, owned))]); var reps = []; // wipe out control variable reps.push(['stat', makeAssign(makeStackAccess(ASM_INT, asmData.controlStackPos(outlineIndex)), ['num', 0])]); @@ -3417,9 +3417,11 @@ function outline(ast) { stats.splice.apply(stats, [start, end-start+1].concat(reps)); // final evaluation and processing if (!extraInfo.allowCostlyOutlines && (measureSize(func) >= funcSize || measureSize(newFunc) >= funcSize)) { + //printErr('aborted outline attempt ' + [measureSize(func), measureSize(newFunc), ' one of which >= ', funcSize]); // abort, this was pointless stats.length = originalStats.length; for (var i = 0; i < stats.length; i++) stats[i] = originalStats[i]; + asmData.splitCounter--; return []; } for (var v in owned) { @@ -3434,6 +3436,7 @@ function outline(ast) { } } outliningParents[newIdent] = func[1]; + printErr('performed outline ' + [func[1], newIdent, 'code sizes (pre/post):', originalCodeSize, measureSize(code), 'overhead (w/r):', setSize(setSub(codeInfo.writes, owned)), setSize(setSub(codeInfo.reads, owned))]); calculateThreshold(func); return [newFunc]; } @@ -3518,7 +3521,7 @@ function outline(ast) { // If this is big enough to outline, but not too big (if very close to the size of the full function, // outlining is pointless; remove stats from the end to try to achieve the good case), then outline. // Also, try to reduce the size if it is much larger than the hoped-for size - while ((sizeSeen > maxSize || sizeSeen > 2*sizeToOutline) && end > i+1 && stats[end][0] !== 'begin-outline-call' && stats[end][0] !== 'end-outline-call') { + while ((sizeSeen > maxSize || sizeSeen > 2*sizeToOutline) && end > i && stats[end][0] !== 'begin-outline-call' && stats[end][0] !== 'end-outline-call') { sizeSeen -= measureSize(stats[end]); if (sizeSeen >= sizeToOutline) { end--; @@ -3540,12 +3543,12 @@ function outline(ast) { }); assert(sum == 0); // final decision and action + //printErr(' will try done working on sizeSeen due to ' + [(sizeSeen > maxSize || sizeSeen > 2*sizeToOutline), end > i , stats[end][0] !== 'begin-outline-call' , stats[end][0] !== 'end-outline-call'] + ' ... ' + [sizeSeen, sizeToOutline, maxSize, sizeSeen >= sizeToOutline, sizeSeen <= maxSize]); if (sizeSeen >= sizeToOutline && sizeSeen <= maxSize) { assert(i >= minIndex); var newFuncs = doOutline(func, asmData, stats, i, end); // outline [i, .. ,end] inclusive if (newFuncs.length) { ret.push.apply(ret, newFuncs); - printErr('performed outline on ' + func[1] + ' of ' + sizeSeen + ', => ' + newFuncs[0][1]); } sizeSeen = 0; end = i-1; |