aboutsummaryrefslogtreecommitdiff
path: root/tools/js-optimizer.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-07-23 17:29:02 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-07-23 17:29:02 -0700
commit1ce927b5d318c16726bc250b09e603020d38420c (patch)
tree5ff9a0ab7b862de698bcab10e7be86b6a672f4ed /tools/js-optimizer.js
parent61e16a2bf7aa86a8432dde69819b66fbf3bf6d18 (diff)
do not outline through an outline call
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r--tools/js-optimizer.js21
1 files changed, 19 insertions, 2 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 51e38817..a7f1e4e1 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -3312,8 +3312,12 @@ function outline(ast) {
if (v != 'sp') newAsmData.vars[v] = getAsmType(v, asmData);
}
denormalizeAsm(newFunc, newAsmData);
+ // add outline call markers (we cannot do later outlinings that cut through an outlining call)
+ reps.unshift(['begin-outline-call', newIdent]);
+ reps.push(['end-outline-call', newIdent]);
// replace in stats
stats.splice.apply(stats, [start, end-start+1].concat(reps));
+ // final evaluation and processing
if (!extraInfo.allowCostlyOutlines && (measureSize(func) >= funcSize || measureSize(newFunc) >= funcSize)) {
// abort, this was pointless
stats.length = originalStats.length;
@@ -3366,6 +3370,14 @@ function outline(ast) {
}
}
var stat = stats[i];
+ if (stat[0] === 'end-outline-call') {
+ // we cannot outline through an outline call, so include all of it
+ while (stats[i--][0] !== 'begin-outline-call') {
+ assert(i >= 0);
+ }
+ assert(i >= 0);
+ stat = stats[i];
+ }
var size = measureSize(stat);
//printErr(level + ' size ' + [i, size]);
if (size >= sizeToOutline) {
@@ -3391,10 +3403,10 @@ function outline(ast) {
}
}
sizeSeen += size;
- // If this is big enough to outline, but no too big (if very close to the size of the full function,
+ // 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) && i < end) {
+ while ((sizeSeen > maxSize || sizeSeen > 2*sizeToOutline) && i < end && stats[i][0] !== 'end-outline-call') {
sizeSeen -= measureSize(stats[end]);
if (sizeSeen >= sizeToOutline) {
end--;
@@ -3502,6 +3514,11 @@ function outline(ast) {
//more = funcs.length > 0;
}
}
+
+ // clear out markers
+ traverse(ast, function(node, type) {
+ if (type === 'begin-outline-call' || type === 'end-outline-call') return emptyNode();
+ });
}
// Last pass utilities