aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-07-24 20:06:54 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-07-24 20:06:54 -0700
commit9aa1c31c714c959fe114191c92b22ea8c4f6d122 (patch)
treeb34eabba5d03f0ab9cb6f4f9bf326446b6e64797 /tools
parentd1bf01006240e8d17eab7720208f731fd93d2751 (diff)
flatten if chains in outliner, and be more careful to avoid outlining through an outline call
Diffstat (limited to 'tools')
-rw-r--r--tools/js-optimizer.js83
-rw-r--r--tools/test-js-optimizer-asm-outline1-output.js131
-rw-r--r--tools/test-js-optimizer-asm-outline1.js29
-rw-r--r--tools/test-js-optimizer-asm-outline2-output.js112
4 files changed, 300 insertions, 55 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index a7f1e4e1..5baac7f6 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -2997,6 +2997,63 @@ function outline(ast) {
});
}
+ // Try to flatten out code as much as possible, to make outlining more feasible.
+ function flatten(func, asmData) {
+ var minSize = sizeToOutline/3;
+ var helperId = 0;
+ function getHelper() {
+ while (1) {
+ var ret = 'helper$' + (helperId++);
+ if (!(ret in asmData.vars) && !(ret in asmData.params)) {
+ asmData.vars[ret] = ASM_INT;
+ return ret;
+ }
+ }
+ }
+ traverse(func, function(node) {
+ var stats = getStatements(node);
+ if (stats) {
+ for (var i = 0; i < stats.length; i++) {
+ var node = stats[i]; // step over param
+ var type = node[0];
+ if (measureSize(node) >= minSize) {
+ if (type === 'if') {
+ var reps = [];
+ var helper = getHelper();
+ // clear helper
+ reps.push(['stat', ['assign', true, ['name', helper], ['num', 1]]]);
+ // gather parts
+ var parts = [];
+ var curr = node;
+ while (1) {
+ parts.push({ condition: curr[1], body: curr[2] });
+ curr = curr[3];
+ if (!curr) break;
+ if (curr[0] != 'if') {
+ parts.push({ condition: null, body: curr });
+ break;
+ }
+ }
+ // generate flattened code
+ parts.forEach(function(part) {
+ var condition = ['name', helper];
+ if (part.condition) condition = ['conditional', condition, part.condition, ['num', 0]];
+ assert(part.body[0] == 'block');
+ reps.push(makeIf(condition, part.body[1]));
+ getStatements(part.body).unshift(['stat', ['assign', true, ['name', helper], ['num', 0]]]);
+ });
+ // replace code and update i
+ stats.splice.apply(stats, [i, 1].concat(reps));
+ i--; // negate loop increment
+ i += reps.length;
+ continue;
+ }
+ }
+ }
+ }
+ });
+ }
+
// Prepares information for spilling of local variables
function analyzeFunction(func, asmData) {
var stack = []; // list of variables, each gets 8 bytes
@@ -3369,15 +3426,17 @@ function outline(ast) {
break;
}
}
+
var stat = stats[i];
- if (stat[0] === 'end-outline-call') {
+ while (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);
+ while (stats[--i][0] !== 'begin-outline-call') {
+ assert(i >= 1);
+ assert(stats[i][0] !== 'end-outline-call');
}
- assert(i >= 0);
stat = stats[i];
}
+
var size = measureSize(stat);
//printErr(level + ' size ' + [i, size]);
if (size >= sizeToOutline) {
@@ -3406,7 +3465,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) && i < end && stats[i][0] !== 'end-outline-call') {
+ while ((sizeSeen > maxSize || sizeSeen > 2*sizeToOutline) && end > i+1 && stats[end][0] !== 'begin-outline-call' && stats[end][0] !== 'end-outline-call') {
sizeSeen -= measureSize(stats[end]);
if (sizeSeen >= sizeToOutline) {
end--;
@@ -3415,6 +3474,19 @@ function outline(ast) {
break;
}
}
+ // verify we are not outlining through an outline call
+ var sum = 0;
+ stats.slice(i, end+1).forEach(function(stat) {
+ if (stat[0] == 'begin-outline-call') {
+ assert(sum == 0);
+ sum++;
+ } else if (stat[0] == 'end-outline-call') {
+ assert(sum == 1);
+ sum--;
+ }
+ });
+ assert(sum == 0);
+ // final decision and action
if (sizeSeen >= sizeToOutline && sizeSeen <= maxSize) {
ret.push.apply(ret, doOutline(func, asmData, stats, i, end)); // outline [i, .. ,end] inclusive
printErr('performed outline on ' + func[1] + ' of ' + sizeSeen + ', func is now size ' + measureSize(func));
@@ -3449,6 +3521,7 @@ function outline(ast) {
if (size >= sizeToOutline) {
printErr('trying to reduce the size of ' + func[1] + ' which is ' + size + ' (>= ' + sizeToOutline + ')');
aggressiveVariableElimination(func, asmData);
+ flatten(func, asmData);
analyzeFunction(func, asmData);
var stats = getStatements(func);
var ret = outlineStatements(func, asmData, stats, 0.9*size);
diff --git a/tools/test-js-optimizer-asm-outline1-output.js b/tools/test-js-optimizer-asm-outline1-output.js
index 8d1071a9..6c4ca85d 100644
--- a/tools/test-js-optimizer-asm-outline1-output.js
+++ b/tools/test-js-optimizer-asm-outline1-output.js
@@ -273,6 +273,43 @@ function vars_w_stack(x, y) {
a = HEAP32[sp + 40 >> 2] | 0;
b = +HEAPF32[sp + 48 >> 2];
}
+function chain() {
+ var helper$0 = 0, sp = 0;
+ sp = STACKTOP;
+ STACKTOP = STACKTOP + 176 | 0;
+ helper$0 = 1;
+ HEAP32[sp + 56 >> 2] = 0;
+ HEAP32[sp + 60 >> 2] = 0;
+ HEAP32[sp + 8 >> 2] = helper$0;
+ sp = chain$5(sp) | 0;
+ helper$0 = HEAP32[sp + 8 >> 2] | 0;
+ HEAP32[sp + 48 >> 2] = 0;
+ HEAP32[sp + 52 >> 2] = 0;
+ HEAP32[sp + 8 >> 2] = helper$0;
+ sp = chain$4(sp) | 0;
+ helper$0 = HEAP32[sp + 8 >> 2] | 0;
+ HEAP32[sp + 40 >> 2] = 0;
+ HEAP32[sp + 44 >> 2] = 0;
+ HEAP32[sp + 8 >> 2] = helper$0;
+ sp = chain$3(sp) | 0;
+ helper$0 = HEAP32[sp + 8 >> 2] | 0;
+ HEAP32[sp + 32 >> 2] = 0;
+ HEAP32[sp + 36 >> 2] = 0;
+ HEAP32[sp + 8 >> 2] = helper$0;
+ sp = chain$2(sp) | 0;
+ helper$0 = HEAP32[sp + 8 >> 2] | 0;
+ HEAP32[sp + 24 >> 2] = 0;
+ HEAP32[sp + 28 >> 2] = 0;
+ HEAP32[sp + 8 >> 2] = helper$0;
+ sp = chain$1(sp) | 0;
+ helper$0 = HEAP32[sp + 8 >> 2] | 0;
+ HEAP32[sp + 16 >> 2] = 0;
+ HEAP32[sp + 20 >> 2] = 0;
+ HEAP32[sp + 8 >> 2] = helper$0;
+ sp = chain$0(sp) | 0;
+ helper$0 = HEAP32[sp + 8 >> 2] | 0;
+ STACKTOP = sp;
+}
function lin$0(sp) {
sp = sp | 0;
c(13);
@@ -563,4 +600,98 @@ function vars_w_stack$1(sp) {
HEAP32[sp + 40 >> 2] = a;
return sp | 0;
}
+function chain$0(sp) {
+ sp = sp | 0;
+ var helper$0 = 0;
+ helper$0 = HEAP32[sp + 8 >> 2] | 0;
+ if (helper$0 ? x == 11 : 0) {
+ helper$0 = 0;
+ print(11);
+ }
+ if (helper$0 ? x == 12 : 0) {
+ helper$0 = 0;
+ print(12);
+ }
+ if (helper$0) {
+ helper$0 = 0;
+ print(99);
+ }
+ HEAP32[sp + 8 >> 2] = helper$0;
+ return sp | 0;
+}
+function chain$1(sp) {
+ sp = sp | 0;
+ var helper$0 = 0;
+ helper$0 = HEAP32[sp + 8 >> 2] | 0;
+ if (helper$0 ? x == 9 : 0) {
+ helper$0 = 0;
+ print(9);
+ }
+ if (helper$0 ? x == 10 : 0) {
+ helper$0 = 0;
+ print(10);
+ }
+ HEAP32[sp + 8 >> 2] = helper$0;
+ return sp | 0;
+}
+function chain$2(sp) {
+ sp = sp | 0;
+ var helper$0 = 0;
+ helper$0 = HEAP32[sp + 8 >> 2] | 0;
+ if (helper$0 ? x == 7 : 0) {
+ helper$0 = 0;
+ print(7);
+ }
+ if (helper$0 ? x == 8 : 0) {
+ helper$0 = 0;
+ print(8);
+ }
+ HEAP32[sp + 8 >> 2] = helper$0;
+ return sp | 0;
+}
+function chain$3(sp) {
+ sp = sp | 0;
+ var helper$0 = 0;
+ helper$0 = HEAP32[sp + 8 >> 2] | 0;
+ if (helper$0 ? x == 5 : 0) {
+ helper$0 = 0;
+ print(5);
+ }
+ if (helper$0 ? x == 6 : 0) {
+ helper$0 = 0;
+ print(6);
+ }
+ HEAP32[sp + 8 >> 2] = helper$0;
+ return sp | 0;
+}
+function chain$4(sp) {
+ sp = sp | 0;
+ var helper$0 = 0;
+ helper$0 = HEAP32[sp + 8 >> 2] | 0;
+ if (helper$0 ? x == 3 : 0) {
+ helper$0 = 0;
+ print(3);
+ }
+ if (helper$0 ? x == 4 : 0) {
+ helper$0 = 0;
+ print(4);
+ }
+ HEAP32[sp + 8 >> 2] = helper$0;
+ return sp | 0;
+}
+function chain$5(sp) {
+ sp = sp | 0;
+ var helper$0 = 0;
+ helper$0 = HEAP32[sp + 8 >> 2] | 0;
+ if (helper$0 ? x == 1 : 0) {
+ helper$0 = 0;
+ print(1);
+ }
+ if (helper$0 ? x == 2 : 0) {
+ helper$0 = 0;
+ print(2);
+ }
+ HEAP32[sp + 8 >> 2] = helper$0;
+ return sp | 0;
+}
diff --git a/tools/test-js-optimizer-asm-outline1.js b/tools/test-js-optimizer-asm-outline1.js
index 40026439..311cb206 100644
--- a/tools/test-js-optimizer-asm-outline1.js
+++ b/tools/test-js-optimizer-asm-outline1.js
@@ -230,5 +230,34 @@ function vars_w_stack(x, y) {
b = c(7+a);
STACKTOP = sp;
}
+function chain() {
+ if (x == 1) {
+ print(1);
+ } else if (x == 2) {
+ print(2);
+ } else if (x == 3) {
+ print(3);
+ } else if (x == 4) {
+ print(4);
+ } else if (x == 5) {
+ print(5);
+ } else if (x == 6) {
+ print(6);
+ } else if (x == 7) {
+ print(7);
+ } else if (x == 8) {
+ print(8);
+ } else if (x == 9) {
+ print(9);
+ } else if (x == 10) {
+ print(10);
+ } else if (x == 11) {
+ print(11);
+ } else if (x == 12) {
+ print(12);
+ } else {
+ print(99);
+ }
+}
// EMSCRIPTEN_GENERATED_FUNCTIONS
// EXTRA_INFO: { "sizeToOutline": 30, "allowCostlyOutlines": 1 }
diff --git a/tools/test-js-optimizer-asm-outline2-output.js b/tools/test-js-optimizer-asm-outline2-output.js
index 31bb7bf9..33b37956 100644
--- a/tools/test-js-optimizer-asm-outline2-output.js
+++ b/tools/test-js-optimizer-asm-outline2-output.js
@@ -21,7 +21,7 @@ function linear() {
}
function _free($mem) {
$mem = $mem | 0;
- var $5 = 0, $10 = 0, $16 = 0, $21 = 0, $25 = 0, $26 = 0, $psize_0 = 0, $p_0 = 0, $189 = 0, $194 = 0, sp = 0;
+ var $5 = 0, $10 = 0, $16 = 0, $21 = 0, $25 = 0, $26 = 0, $psize_0 = 0, $p_0 = 0, $189 = 0, $194 = 0, sp = 0, helper$0 = 0;
sp = STACKTOP;
if (($mem | 0) == 0) {
STACKTOP = sp;
@@ -37,7 +37,9 @@ function _free($mem) {
}
$16 = $mem + (($10 & -8) - 8) | 0;
L621 : do {
- if (($10 & 1 | 0) == 0) {
+ helper$0 = 1;
+ if (helper$0 ? ($10 & 1 | 0) == 0 : 0) {
+ helper$0 = 0;
$21 = HEAP32[($mem - 8 | 0) >> 2] | 0;
if (($10 & 3 | 0) == 0) {
return;
@@ -47,8 +49,8 @@ function _free($mem) {
if (($mem + (-8 - $21 | 0) | 0) >>> 0 < $5 >>> 0) {
_abort();
}
- HEAP32[sp + 648 >> 2] = 0;
- HEAP32[sp + 652 >> 2] = 0;
+ HEAP32[sp + 672 >> 2] = 0;
+ HEAP32[sp + 676 >> 2] = 0;
HEAP32[sp + 48 >> 2] = $25;
HEAP32[sp + 8 >> 2] = $mem;
HEAP32[sp + 24 >> 2] = $10;
@@ -60,11 +62,11 @@ function _free($mem) {
sp = _free$1(sp) | 0;
$p_0 = HEAP32[sp + 224 >> 2] | 0;
$psize_0 = HEAP32[sp + 216 >> 2] | 0;
- tempValue = HEAP32[sp + 648 >> 2] | 0;
- tempInt = HEAP32[sp + 652 >> 2] | 0;
- tempDouble = +HEAPF32[sp + 652 >> 2];
- HEAP32[sp + 648 >> 2] = 0;
- HEAP32[sp + 652 >> 2] = 0;
+ tempValue = HEAP32[sp + 672 >> 2] | 0;
+ tempInt = HEAP32[sp + 676 >> 2] | 0;
+ tempDouble = +HEAPF32[sp + 676 >> 2];
+ HEAP32[sp + 672 >> 2] = 0;
+ HEAP32[sp + 676 >> 2] = 0;
if ((tempValue | 0) == 5) {
return;
}
@@ -79,7 +81,9 @@ function _free($mem) {
}
}
}
- } else {
+ }
+ if (helper$0) {
+ helper$0 = 0;
$p_0 = $mem - 8 | 0;
$psize_0 = $10 & -8;
}
@@ -92,8 +96,8 @@ function _free($mem) {
if (($194 & 1 | 0) == 0) {
_abort();
}
- HEAP32[sp + 656 >> 2] = 0;
- HEAP32[sp + 660 >> 2] = 0;
+ HEAP32[sp + 680 >> 2] = 0;
+ HEAP32[sp + 684 >> 2] = 0;
HEAP32[sp + 240 >> 2] = $194;
HEAP32[sp + 32 >> 2] = $16;
HEAP32[sp + 216 >> 2] = $psize_0;
@@ -102,11 +106,11 @@ function _free($mem) {
HEAP32[sp + 8 >> 2] = $mem;
HEAP32[sp + 24 >> 2] = $10;
sp = _free$2(sp) | 0;
- tempValue = HEAP32[sp + 656 >> 2] | 0;
- tempInt = HEAP32[sp + 660 >> 2] | 0;
- tempDouble = +HEAPF32[sp + 660 >> 2];
- HEAP32[sp + 656 >> 2] = 0;
- HEAP32[sp + 660 >> 2] = 0;
+ tempValue = HEAP32[sp + 680 >> 2] | 0;
+ tempInt = HEAP32[sp + 684 >> 2] | 0;
+ tempDouble = +HEAPF32[sp + 684 >> 2];
+ HEAP32[sp + 680 >> 2] = 0;
+ HEAP32[sp + 684 >> 2] = 0;
if ((tempValue | 0) == 5) {
return;
}
@@ -147,7 +151,7 @@ function linear$1(sp) {
}
function _free$0(sp) {
sp = sp | 0;
- var $16 = 0, $220 = 0, $psize_0 = 0, $p_0 = 0, $189 = 0, $227 = 0, $194 = 0, $233 = 0, $mem = 0, $10 = 0, $236 = 0, $_pre_phi305 = 0, $267 = 0, $270 = 0, $273 = 0, $294 = 0, $299 = 0, $R7_1 = 0, $R7_0 = 0, $RP9_0 = 0, $301 = 0, $302 = 0, $305 = 0, $306 = 0, $278 = 0, $320 = 0, $351 = 0, $364 = 0, $psize_1 = 0;
+ var $16 = 0, $220 = 0, $psize_0 = 0, $p_0 = 0, $189 = 0, $227 = 0, $194 = 0, helper$2 = 0, $233 = 0, $mem = 0, $10 = 0, $236 = 0, $_pre_phi305 = 0, $267 = 0, $270 = 0, $273 = 0, $294 = 0, $299 = 0, $R7_1 = 0, $R7_0 = 0, $RP9_0 = 0, $301 = 0, $302 = 0, $305 = 0, $306 = 0, $278 = 0, $320 = 0, $351 = 0, $364 = 0, $psize_1 = 0;
$psize_1 = HEAP32[sp + 424 >> 2] | 0;
$10 = HEAP32[sp + 24 >> 2] | 0;
$mem = HEAP32[sp + 8 >> 2] | 0;
@@ -163,12 +167,14 @@ function _free$0(sp) {
HEAP32[25] = $p_0;
HEAP32[$p_0 + 4 >> 2] = $220 | 1;
HEAP32[$189 + $220 >> 2] = $220;
- HEAP32[sp + 640 >> 2] = 5;
+ HEAP32[sp + 664 >> 2] = 5;
break OL;
}
$227 = ($194 & -8) + $psize_0 | 0;
L726 : do {
- if ($194 >>> 0 < 256) {
+ helper$2 = 1;
+ if (helper$2 ? $194 >>> 0 < 256 : 0) {
+ helper$2 = 0;
$233 = HEAP32[$mem + ($10 & -8) >> 2] | 0;
$236 = HEAP32[$mem + ($10 & -8 | 4) >> 2] | 0;
do {
@@ -202,7 +208,9 @@ function _free$0(sp) {
} while (0);
HEAP32[$233 + 12 >> 2] = $236;
HEAP32[$_pre_phi305 >> 2] = $233;
- } else {
+ }
+ if (helper$2) {
+ helper$2 = 0;
$267 = $mem + (($10 & -8) - 8) | 0;
$270 = HEAP32[$mem + (($10 & -8) + 16) >> 2] | 0;
$273 = HEAP32[$mem + ($10 & -8 | 4) >> 2] | 0;
@@ -323,11 +331,11 @@ function _free$0(sp) {
HEAP32[$189 + $227 >> 2] = $227;
if (($p_0 | 0) != (HEAP32[25] | 0)) {
$psize_1 = $227;
- HEAP32[sp + 640 >> 2] = 1;
+ HEAP32[sp + 664 >> 2] = 1;
break OL;
}
HEAP32[22] = $227;
- HEAP32[sp + 640 >> 2] = 5;
+ HEAP32[sp + 664 >> 2] = 5;
break OL;
} while (0);
HEAP32[sp + 424 >> 2] = $psize_1;
@@ -349,14 +357,14 @@ function _free$1(sp) {
if ((HEAP32[($mem + (($10 & -8) - 4) | 0) >> 2] & 3 | 0) != 3) {
$p_0 = $25;
$psize_0 = $26;
- HEAP32[sp + 648 >> 2] = 1;
+ HEAP32[sp + 672 >> 2] = 1;
break OL;
}
HEAP32[22] = $26;
HEAP32[($mem + (($10 & -8) - 4) | 0) >> 2] = HEAP32[($mem + (($10 & -8) - 4) | 0) >> 2] & -2;
HEAP32[$mem + ((-8 - $21 | 0) + 4) >> 2] = $26 | 1;
HEAP32[($mem + (($10 & -8) - 8) | 0) >> 2] = $26;
- HEAP32[sp + 648 >> 2] = 5;
+ HEAP32[sp + 672 >> 2] = 5;
break OL;
}
if ($21 >>> 0 < 256) {
@@ -377,7 +385,7 @@ function _free$1(sp) {
HEAP32[20] = HEAP32[20] & (1 << ($21 >>> 3) ^ -1);
$p_0 = $25;
$psize_0 = $26;
- HEAP32[sp + 648 >> 2] = 1;
+ HEAP32[sp + 672 >> 2] = 1;
break OL;
}
do {
@@ -398,7 +406,7 @@ function _free$1(sp) {
HEAP32[$_pre_phi307 >> 2] = $37;
$p_0 = $25;
$psize_0 = $26;
- HEAP32[sp + 648 >> 2] = 1;
+ HEAP32[sp + 672 >> 2] = 1;
break OL;
}
$69 = $mem + (-8 - $21 | 0) | 0;
@@ -465,7 +473,7 @@ function _free$1(sp) {
if (($72 | 0) == 0) {
$p_0 = $25;
$psize_0 = $26;
- HEAP32[sp + 648 >> 2] = 1;
+ HEAP32[sp + 672 >> 2] = 1;
break OL;
}
$120 = 384 + (HEAP32[($mem + ((-8 - $21 | 0) + 28) | 0) >> 2] << 2) | 0;
@@ -478,8 +486,8 @@ function _free$1(sp) {
HEAP32[21] = HEAP32[21] & (1 << HEAP32[($mem + ((-8 - $21 | 0) + 28) | 0) >> 2] ^ -1);
$p_0 = $25;
$psize_0 = $26;
- HEAP32[sp + 648 >> 2] = 2;
- HEAP32[sp + 652 >> 2] = 2;
+ HEAP32[sp + 672 >> 2] = 2;
+ HEAP32[sp + 676 >> 2] = 2;
break OL;
} else {
if ($72 >>> 0 < (HEAP32[24] | 0) >>> 0) {
@@ -493,8 +501,8 @@ function _free$1(sp) {
if (($R_1 | 0) == 0) {
$p_0 = $25;
$psize_0 = $26;
- HEAP32[sp + 648 >> 2] = 2;
- HEAP32[sp + 652 >> 2] = 2;
+ HEAP32[sp + 672 >> 2] = 2;
+ HEAP32[sp + 676 >> 2] = 2;
break OL;
}
}
@@ -519,7 +527,7 @@ function _free$1(sp) {
if (($164 | 0) == 0) {
$p_0 = $25;
$psize_0 = $26;
- HEAP32[sp + 648 >> 2] = 1;
+ HEAP32[sp + 672 >> 2] = 1;
break OL;
}
if ($164 >>> 0 < (HEAP32[24] | 0) >>> 0) {
@@ -529,7 +537,7 @@ function _free$1(sp) {
HEAP32[$164 + 24 >> 2] = $R_1;
$p_0 = $25;
$psize_0 = $26;
- HEAP32[sp + 648 >> 2] = 1;
+ HEAP32[sp + 672 >> 2] = 1;
break OL;
}
} while (0);
@@ -539,7 +547,7 @@ function _free$1(sp) {
}
function _free$2(sp) {
sp = sp | 0;
- var $194 = 0, $16 = 0, $204 = 0, $psize_0 = 0, $p_0 = 0, $189 = 0, $mem = 0, $10 = 0, $psize_1 = 0, $390 = 0, $396 = 0, $F16_0 = 0, $_pre_phi = 0, $404 = 0, $414 = 0, $415 = 0, $I18_0 = 0, $428 = 0, $436 = 0, $443 = 0, $447 = 0, $448 = 0, $463 = 0, $K19_0 = 0, $T_0 = 0, $472 = 0, $473 = 0, label = 0, $486 = 0, $487 = 0, $489 = 0, $501 = 0, $sp_0_in_i = 0, $sp_0_i = 0;
+ var helper$1 = 0, $194 = 0, $16 = 0, $204 = 0, $psize_0 = 0, $p_0 = 0, $189 = 0, $mem = 0, $10 = 0, $psize_1 = 0, $390 = 0, $396 = 0, $F16_0 = 0, $_pre_phi = 0, $404 = 0, $414 = 0, $415 = 0, $I18_0 = 0, $428 = 0, $436 = 0, $443 = 0, $447 = 0, $448 = 0, $463 = 0, $K19_0 = 0, $T_0 = 0, $472 = 0, $473 = 0, label = 0, $486 = 0, $487 = 0, $489 = 0, $501 = 0, $sp_0_in_i = 0, $sp_0_i = 0;
$10 = HEAP32[sp + 24 >> 2] | 0;
$mem = HEAP32[sp + 8 >> 2] | 0;
$189 = HEAP32[sp + 232 >> 2] | 0;
@@ -549,7 +557,9 @@ function _free$2(sp) {
$194 = HEAP32[sp + 240 >> 2] | 0;
OL : do {
do {
- if (($194 & 2 | 0) == 0) {
+ helper$1 = 1;
+ if (helper$1 ? ($194 & 2 | 0) == 0 : 0) {
+ helper$1 = 0;
if (($16 | 0) == (HEAP32[26] | 0)) {
$204 = (HEAP32[23] | 0) + $psize_0 | 0;
HEAP32[23] = $204;
@@ -560,15 +570,15 @@ function _free$2(sp) {
HEAP32[22] = 0;
}
if ($204 >>> 0 <= (HEAP32[27] | 0) >>> 0) {
- HEAP32[sp + 656 >> 2] = 5;
+ HEAP32[sp + 680 >> 2] = 5;
break OL;
}
_sys_trim(0) | 0;
- HEAP32[sp + 656 >> 2] = 5;
+ HEAP32[sp + 680 >> 2] = 5;
break OL;
}
- HEAP32[sp + 640 >> 2] = 0;
- HEAP32[sp + 644 >> 2] = 0;
+ HEAP32[sp + 664 >> 2] = 0;
+ HEAP32[sp + 668 >> 2] = 0;
HEAP32[sp + 32 >> 2] = $16;
HEAP32[sp + 216 >> 2] = $psize_0;
HEAP32[sp + 224 >> 2] = $p_0;
@@ -579,19 +589,21 @@ function _free$2(sp) {
HEAP32[sp + 424 >> 2] = $psize_1;
sp = _free$0(sp) | 0;
$psize_1 = HEAP32[sp + 424 >> 2] | 0;
- tempValue = HEAP32[sp + 640 >> 2] | 0;
- tempInt = HEAP32[sp + 644 >> 2] | 0;
- tempDouble = +HEAPF32[sp + 644 >> 2];
- HEAP32[sp + 640 >> 2] = 0;
- HEAP32[sp + 644 >> 2] = 0;
+ tempValue = HEAP32[sp + 664 >> 2] | 0;
+ tempInt = HEAP32[sp + 668 >> 2] | 0;
+ tempDouble = +HEAPF32[sp + 668 >> 2];
+ HEAP32[sp + 664 >> 2] = 0;
+ HEAP32[sp + 668 >> 2] = 0;
if ((tempValue | 0) == 5) {
- HEAP32[sp + 656 >> 2] = 5;
+ HEAP32[sp + 680 >> 2] = 5;
break OL;
}
if ((tempValue | 0) == 1) {
break;
}
- } else {
+ }
+ if (helper$1) {
+ helper$1 = 0;
HEAP32[($mem + (($10 & -8) - 4) | 0) >> 2] = $194 & -2;
HEAP32[$p_0 + 4 >> 2] = $psize_0 | 1;
HEAP32[$189 + $psize_0 >> 2] = $psize_0;
@@ -620,7 +632,7 @@ function _free$2(sp) {
HEAP32[$F16_0 + 12 >> 2] = $p_0;
HEAP32[$p_0 + 8 >> 2] = $F16_0;
HEAP32[$p_0 + 12 >> 2] = 120 + ($390 << 1 << 2) | 0;
- HEAP32[sp + 656 >> 2] = 5;
+ HEAP32[sp + 680 >> 2] = 5;
break OL;
}
$414 = $p_0;
@@ -707,7 +719,7 @@ function _free$2(sp) {
if (($501 | 0) == 0) {
$sp_0_in_i = 536;
} else {
- HEAP32[sp + 656 >> 2] = 5;
+ HEAP32[sp + 680 >> 2] = 5;
break OL;
}
while (1) {
@@ -720,7 +732,7 @@ function _free$2(sp) {
}
HEAP32[28] = -1;
STACKTOP = sp;
- HEAP32[sp + 656 >> 2] = 5;
+ HEAP32[sp + 680 >> 2] = 5;
break OL;
} while (0);
return sp | 0;