aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-07-08 11:40:38 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-07-08 11:40:38 -0700
commit3f75ed559f6a7c2ce609b98250729477a8f766d8 (patch)
tree53f80e09313e9b4b97c3b14072f58979f478086e
parent3117fa129fe2aef34a7c954bfe02c1eb0e5f8d29 (diff)
begin work on outliner pass to break up large functions. part 1: aggressive variable elimination, to reduce spilling
-rw-r--r--src/utility.js10
-rwxr-xr-xtests/runner.py2
-rw-r--r--tools/js-optimizer.js173
-rw-r--r--tools/test-js-optimizer-asm-outline-output.js530
-rw-r--r--tools/test-js-optimizer-asm-outline.js566
5 files changed, 1280 insertions, 1 deletions
diff --git a/src/utility.js b/src/utility.js
index b67e6c21..9cc8d3a3 100644
--- a/src/utility.js
+++ b/src/utility.js
@@ -298,12 +298,20 @@ function setIntersect(x, y) {
var ret = {};
for (xx in x) {
if (xx in y) {
- ret[xx] = true;
+ ret[xx] = 0;
}
}
return ret;
}
+function setUnion(x, y) {
+ var ret = set(keys(x));
+ for (yy in y) {
+ ret[yy] = 0;
+ }
+ return ret;
+}
+
function invertArray(x) {
var ret = {};
for (var i = 0; i < x.length; i++) {
diff --git a/tests/runner.py b/tests/runner.py
index a7f1ea66..6d6d0be6 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -11571,6 +11571,8 @@ f.close()
['asm', 'last']),
(path_from_root('tools', 'test-js-optimizer-asm-relocate.js'), open(path_from_root('tools', 'test-js-optimizer-asm-relocate-output.js')).read(),
['asm', 'relocate']),
+ (path_from_root('tools', 'test-js-optimizer-asm-outline.js'), open(path_from_root('tools', 'test-js-optimizer-asm-outline-output.js')).read(),
+ ['asm', 'outline']),
]:
print input
output = Popen(listify(NODE_JS) + [path_from_root('tools', 'js-optimizer.js'), input] + passes, stdin=PIPE, stdout=PIPE).communicate()[0]
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 0d1e8801..22bab318 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -2788,6 +2788,178 @@ function relocate(ast) {
});
}
+// Break up very large functions
+
+var NODES_WITHOUT_ELIMINATION_SENSITIVITY = set('name', 'num', 'binary', 'unary-prefix');
+var FAST_ELIMINATION_BINARIES = setUnion(setUnion(USEFUL_BINARY_OPS, COMPARE_OPS), set('+'));
+
+function outline(ast) {
+ function measureSize(ast) {
+ var size = 0;
+ traverse(ast, function() {
+ size++;
+ });
+ return size;
+ }
+
+ function aggressiveVariableElimination(func, asmData) {
+ // This removes as many variables as possible. This is often not the best thing because it increases
+ // code size, but it is far preferable to the risk of split functions needing to do more spilling. Specifically,
+ // it finds 'trivial' variables: ones with 1 definition, and that definition is not sensitive to any changes: it
+ // only depends on constants and local variables that are themselves trivial. We can unquestionably eliminate
+ // such variables in a trivial manner.
+
+ var assignments = {};
+ var appearances = {};
+ var defs = {};
+ var considered = {};
+
+ traverse(func, function(node, type) {
+ if (type == 'assign' && node[2][0] == 'name') {
+ var name = node[2][1];
+ if (name in asmData.vars) {
+ assignments[name] = (assignments[name] || 0) + 1;
+ appearances[name] = (appearances[name] || 0) - 1; // this appearance is a definition, offset the counting later
+ defs[name] = node;
+ } else {
+ if (name in asmData.params) {
+ considered[name] = true; // this parameter is not ssa, it must be in a hand-optimized function, so it is not trivial
+ }
+ }
+ } else if (type == 'name') {
+ var name = node[1];
+ if (name in asmData.vars) {
+ appearances[name] = (appearances[name] || 0) + 1;
+ }
+ }
+ });
+
+ var allTrivials = {}; // key of a trivial var => size of its (expanded) value, at least 1
+
+ // three levels of variables:
+ // 1. trivial: 1 def (or less), uses nothing sensitive, can be eliminated
+ // 2. safe: 1 def (or less), can be used in a trivial, but cannot itself be eliminated
+ // 3. sensitive: uses a global or memory or something else that prevents trivial elimination.
+
+ function assessTriviality(name) {
+ // only care about vars with 0-1 assignments of (0 for parameters), and can ignore label (which is not explicitly initialized, but cannot be eliminated ever anyhow)
+ if (assignments[name] > 1 || (!(name in asmData.vars) && !(name in asmData.params)) || name == 'label') return false;
+ if (considered[name]) return allTrivials[name];
+ considered[name] = true;
+ var sensitive = false;
+ var size = 0, originalSize = 0;
+ var def = defs[name];
+ if (def) {
+ var value = def[3];
+ originalSize = measureSize(value);
+ if (value) {
+ traverse(value, function recurseValue(node, type) {
+ var one = node[1];
+ if (!(type in NODES_WITHOUT_ELIMINATION_SENSITIVITY)) { // || (type == 'binary' && !(one in FAST_ELIMINATION_BINARIES))) {
+ sensitive = true;
+ return true;
+ }
+ if (type == 'name' && !assessTriviality(one)) {
+ if (assignments[one] > 1 || (!(one in asmData.vars) && !(one in asmData.params))) {
+ sensitive = true; // directly using something sensitive
+ return true;
+ } // otherwise, not trivial, but at least safe.
+ }
+ // if this is a name, it must be a trivial variable (or a safe one) and we know its size
+ size += ((type == 'name') ? allTrivials[one] : 1) || 1;
+ });
+ }
+ }
+ if (!sensitive) {
+ size = size || 1;
+ originalSize = originalSize || 1;
+ var factor = ((appearances[name] - 1) || 0) * (size - originalSize); // If no size change or just one appearance, always ok to trivially eliminate. otherwise, tradeoff
+ if (factor <= 12) {
+ allTrivials[name] = size; // trivial!
+ return true;
+ }
+ }
+ return false;
+ }
+ for (var name in asmData.vars) {
+ assessTriviality(name);
+ }
+ var trivials = {};
+
+ for (var name in allTrivials) { // from now on, ignore parameters
+ if (name in asmData.vars) trivials[name] = true;
+ }
+
+ allTrivials = {};
+
+ var values = {};
+
+ function evaluate(name) {
+ var node = values[name];
+ if (node) return node;
+ values[node] = null; // prevent infinite recursion
+ var def = defs[name];
+ if (def) {
+ node = def[3];
+ if (node[0] == 'name') {
+ var name2 = node[1];
+ if (name2 in trivials) {
+ node = evaluate(name2);
+ }
+ } else {
+ traverse(node, function(node, type) {
+ if (type == 'name') {
+ var name2 = node[1];
+ if (name2 in trivials) {
+ return evaluate(name2);
+ }
+ }
+ });
+ }
+ values[name] = node;
+ }
+ return node;
+ }
+
+ for (var name in trivials) {
+ evaluate(name);
+ }
+
+ for (var name in trivials) {
+ var def = defs[name];
+ if (def) {
+ def.length = 0;
+ def[0] = 'toplevel';
+ def[1] = [];
+ }
+ delete asmData.vars[name];
+ }
+
+ // Perform replacements TODO: save list of uses objects before, replace directly, avoid extra traverse
+ traverse(func, function(node, type) {
+ if (type == 'name') {
+ var name = node[1];
+ if (name in trivials) {
+ var value = values[name];
+ if (!value) throw 'missing value: ' + [func[1], name, values[name]] + ' - faulty reliance on asm zero-init?';
+ return copy(value); // must copy, or else the same object can be used multiple times
+ }
+ }
+ });
+ }
+
+ var sizeToOutline = extraInfo.sizeToOutline;
+
+ traverseGeneratedFunctions(ast, function(func) {
+ var asmData = normalizeAsm(func);
+ var size = measureSize(func);
+ if (size >= sizeToOutline) {
+ aggressiveVariableElimination(func, asmData);
+ }
+ denormalizeAsm(func, asmData);
+ });
+}
+
// Last pass utilities
// Change +5 to DOT$ZERO(5). We then textually change 5 to 5.0 (uglify's ast cannot differentiate between 5 and 5.0 directly)
@@ -2872,6 +3044,7 @@ var passes = {
eliminateMemSafe: eliminateMemSafe,
minifyGlobals: minifyGlobals,
relocate: relocate,
+ outline: outline,
minifyWhitespace: function() { minifyWhitespace = true },
noPrintMetadata: function() { printMetadata = false },
asm: function() { asm = true },
diff --git a/tools/test-js-optimizer-asm-outline-output.js b/tools/test-js-optimizer-asm-outline-output.js
new file mode 100644
index 00000000..f601437e
--- /dev/null
+++ b/tools/test-js-optimizer-asm-outline-output.js
@@ -0,0 +1,530 @@
+function _free($mem) {
+ $mem = $mem | 0;
+ var $5 = 0, $10 = 0, $16 = 0, $21 = 0, $25 = 0, $26 = 0, $37 = 0, $40 = 0, $_pre_phi307 = 0, $69 = 0, $72 = 0, $75 = 0, $80 = 0, $95 = 0, $100 = 0, $RP_0 = 0, $R_0 = 0, $102 = 0, $103 = 0, $106 = 0, $107 = 0, $R_1 = 0, $120 = 0, $151 = 0, $164 = 0, $psize_0 = 0, $p_0 = 0, $189 = 0, $194 = 0, $204 = 0, $220 = 0, $227 = 0, $233 = 0, $236 = 0, $_pre_phi305 = 0, $267 = 0, $270 = 0, $273 = 0, $278 = 0, $294 = 0, $299 = 0, $RP9_0 = 0, $R7_0 = 0, $301 = 0, $302 = 0, $305 = 0, $306 = 0, $R7_1 = 0, $320 = 0, $351 = 0, $364 = 0, $psize_1 = 0, $390 = 0, $396 = 0, $404 = 0, $_pre_phi = 0, $F16_0 = 0, $414 = 0, $415 = 0, $428 = 0, $436 = 0, $I18_0 = 0, $443 = 0, $447 = 0, $448 = 0, $463 = 0, $T_0 = 0, $K19_0 = 0, $472 = 0, $473 = 0, $486 = 0, $487 = 0, $489 = 0, $501 = 0, $sp_0_in_i = 0, $sp_0_i = 0, label = 0;
+ if (($mem | 0) == 0) {
+ return;
+ }
+ $5 = HEAP32[24] | 0;
+ if (($mem - 8 | 0) >>> 0 < $5 >>> 0) {
+ _abort();
+ }
+ $10 = HEAP32[$mem - 4 >> 2] | 0;
+ if (($10 & 3 | 0) == 1) {
+ _abort();
+ }
+ $16 = $mem + (($10 & -8) - 8) | 0;
+ L621 : do {
+ if (($10 & 1 | 0) == 0) {
+ $21 = HEAP32[($mem - 8 | 0) >> 2] | 0;
+ if (($10 & 3 | 0) == 0) {
+ return;
+ }
+ $25 = $mem + (-8 - $21 | 0) | 0;
+ $26 = $21 + ($10 & -8) | 0;
+ if (($mem + (-8 - $21 | 0) | 0) >>> 0 < $5 >>> 0) {
+ _abort();
+ }
+ if (($25 | 0) == (HEAP32[25] | 0)) {
+ if ((HEAP32[($mem + (($10 & -8) - 4) | 0) >> 2] & 3 | 0) != 3) {
+ $p_0 = $25;
+ $psize_0 = $26;
+ break;
+ }
+ 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;
+ return;
+ }
+ if ($21 >>> 0 < 256) {
+ $37 = HEAP32[$mem + ((-8 - $21 | 0) + 8) >> 2] | 0;
+ $40 = HEAP32[$mem + ((-8 - $21 | 0) + 12) >> 2] | 0;
+ do {
+ if (($37 | 0) != (120 + ($21 >>> 3 << 1 << 2) | 0 | 0)) {
+ if ($37 >>> 0 < $5 >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[$37 + 12 >> 2] | 0) == ($25 | 0)) {
+ break;
+ }
+ _abort();
+ }
+ } while (0);
+ if (($40 | 0) == ($37 | 0)) {
+ HEAP32[20] = HEAP32[20] & (1 << ($21 >>> 3) ^ -1);
+ $p_0 = $25;
+ $psize_0 = $26;
+ break;
+ }
+ do {
+ if (($40 | 0) == (120 + ($21 >>> 3 << 1 << 2) | 0 | 0)) {
+ $_pre_phi307 = $40 + 8 | 0;
+ } else {
+ if ($40 >>> 0 < $5 >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[($40 + 8 | 0) >> 2] | 0) == ($25 | 0)) {
+ $_pre_phi307 = $40 + 8 | 0;
+ break;
+ }
+ _abort();
+ }
+ } while (0);
+ HEAP32[$37 + 12 >> 2] = $40;
+ HEAP32[$_pre_phi307 >> 2] = $37;
+ $p_0 = $25;
+ $psize_0 = $26;
+ break;
+ }
+ $69 = $mem + (-8 - $21 | 0) | 0;
+ $72 = HEAP32[$mem + ((-8 - $21 | 0) + 24) >> 2] | 0;
+ $75 = HEAP32[$mem + ((-8 - $21 | 0) + 12) >> 2] | 0;
+ do {
+ if (($75 | 0) == ($69 | 0)) {
+ $95 = HEAP32[($mem + ((-8 - $21 | 0) + 20) | 0) >> 2] | 0;
+ if (($95 | 0) == 0) {
+ $100 = HEAP32[($mem + ((-8 - $21 | 0) + 16) | 0) >> 2] | 0;
+ if (($100 | 0) == 0) {
+ $R_1 = 0;
+ break;
+ } else {
+ $R_0 = $100;
+ $RP_0 = $mem + ((-8 - $21 | 0) + 16) | 0;
+ }
+ } else {
+ $R_0 = $95;
+ $RP_0 = $mem + ((-8 - $21 | 0) + 20) | 0;
+ }
+ while (1) {
+ $102 = $R_0 + 20 | 0;
+ $103 = HEAP32[$102 >> 2] | 0;
+ if (($103 | 0) != 0) {
+ $R_0 = $103;
+ $RP_0 = $102;
+ continue;
+ }
+ $106 = $R_0 + 16 | 0;
+ $107 = HEAP32[$106 >> 2] | 0;
+ if (($107 | 0) == 0) {
+ break;
+ } else {
+ $R_0 = $107;
+ $RP_0 = $106;
+ }
+ }
+ if ($RP_0 >>> 0 < $5 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[$RP_0 >> 2] = 0;
+ $R_1 = $R_0;
+ break;
+ }
+ } else {
+ $80 = HEAP32[$mem + ((-8 - $21 | 0) + 8) >> 2] | 0;
+ if ($80 >>> 0 < $5 >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[($80 + 12 | 0) >> 2] | 0) != ($69 | 0)) {
+ _abort();
+ }
+ if ((HEAP32[($75 + 8 | 0) >> 2] | 0) == ($69 | 0)) {
+ HEAP32[($80 + 12 | 0) >> 2] = $75;
+ HEAP32[($75 + 8 | 0) >> 2] = $80;
+ $R_1 = $75;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if (($72 | 0) == 0) {
+ $p_0 = $25;
+ $psize_0 = $26;
+ break;
+ }
+ $120 = 384 + (HEAP32[($mem + ((-8 - $21 | 0) + 28) | 0) >> 2] << 2) | 0;
+ do {
+ if (($69 | 0) == (HEAP32[$120 >> 2] | 0)) {
+ HEAP32[$120 >> 2] = $R_1;
+ if (($R_1 | 0) != 0) {
+ break;
+ }
+ HEAP32[21] = HEAP32[21] & (1 << HEAP32[($mem + ((-8 - $21 | 0) + 28) | 0) >> 2] ^ -1);
+ $p_0 = $25;
+ $psize_0 = $26;
+ break L621;
+ } else {
+ if ($72 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[($72 + 16 | 0) >> 2] | 0) == ($69 | 0)) {
+ HEAP32[($72 + 16 | 0) >> 2] = $R_1;
+ } else {
+ HEAP32[$72 + 20 >> 2] = $R_1;
+ }
+ if (($R_1 | 0) == 0) {
+ $p_0 = $25;
+ $psize_0 = $26;
+ break L621;
+ }
+ }
+ } while (0);
+ if ($R_1 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[$R_1 + 24 >> 2] = $72;
+ $151 = HEAP32[$mem + ((-8 - $21 | 0) + 16) >> 2] | 0;
+ do {
+ if (($151 | 0) != 0) {
+ if ($151 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[$R_1 + 16 >> 2] = $151;
+ HEAP32[$151 + 24 >> 2] = $R_1;
+ break;
+ }
+ }
+ } while (0);
+ $164 = HEAP32[$mem + ((-8 - $21 | 0) + 20) >> 2] | 0;
+ if (($164 | 0) == 0) {
+ $p_0 = $25;
+ $psize_0 = $26;
+ break;
+ }
+ if ($164 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[$R_1 + 20 >> 2] = $164;
+ HEAP32[$164 + 24 >> 2] = $R_1;
+ $p_0 = $25;
+ $psize_0 = $26;
+ break;
+ }
+ } else {
+ $p_0 = $mem - 8 | 0;
+ $psize_0 = $10 & -8;
+ }
+ } while (0);
+ $189 = $p_0;
+ if ($189 >>> 0 >= ($mem + (($10 & -8) - 8) | 0) >>> 0) {
+ _abort();
+ }
+ $194 = HEAP32[($mem + (($10 & -8) - 4) | 0) >> 2] | 0;
+ if (($194 & 1 | 0) == 0) {
+ _abort();
+ }
+ do {
+ if (($194 & 2 | 0) == 0) {
+ if (($16 | 0) == (HEAP32[26] | 0)) {
+ $204 = (HEAP32[23] | 0) + $psize_0 | 0;
+ HEAP32[23] = $204;
+ HEAP32[26] = $p_0;
+ HEAP32[$p_0 + 4 >> 2] = $204 | 1;
+ if (($p_0 | 0) == (HEAP32[25] | 0)) {
+ HEAP32[25] = 0;
+ HEAP32[22] = 0;
+ }
+ if ($204 >>> 0 <= (HEAP32[27] | 0) >>> 0) {
+ return;
+ }
+ _sys_trim(0) | 0;
+ return;
+ }
+ if (($16 | 0) == (HEAP32[25] | 0)) {
+ $220 = (HEAP32[22] | 0) + $psize_0 | 0;
+ HEAP32[22] = $220;
+ HEAP32[25] = $p_0;
+ HEAP32[$p_0 + 4 >> 2] = $220 | 1;
+ HEAP32[$189 + $220 >> 2] = $220;
+ return;
+ }
+ $227 = ($194 & -8) + $psize_0 | 0;
+ L726 : do {
+ if ($194 >>> 0 < 256) {
+ $233 = HEAP32[$mem + ($10 & -8) >> 2] | 0;
+ $236 = HEAP32[$mem + ($10 & -8 | 4) >> 2] | 0;
+ do {
+ if (($233 | 0) != (120 + ($194 >>> 3 << 1 << 2) | 0 | 0)) {
+ if ($233 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[$233 + 12 >> 2] | 0) == ($16 | 0)) {
+ break;
+ }
+ _abort();
+ }
+ } while (0);
+ if (($236 | 0) == ($233 | 0)) {
+ HEAP32[20] = HEAP32[20] & (1 << ($194 >>> 3) ^ -1);
+ break;
+ }
+ do {
+ if (($236 | 0) == (120 + ($194 >>> 3 << 1 << 2) | 0 | 0)) {
+ $_pre_phi305 = $236 + 8 | 0;
+ } else {
+ if ($236 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[($236 + 8 | 0) >> 2] | 0) == ($16 | 0)) {
+ $_pre_phi305 = $236 + 8 | 0;
+ break;
+ }
+ _abort();
+ }
+ } while (0);
+ HEAP32[$233 + 12 >> 2] = $236;
+ HEAP32[$_pre_phi305 >> 2] = $233;
+ } else {
+ $267 = $mem + (($10 & -8) - 8) | 0;
+ $270 = HEAP32[$mem + (($10 & -8) + 16) >> 2] | 0;
+ $273 = HEAP32[$mem + ($10 & -8 | 4) >> 2] | 0;
+ do {
+ if (($273 | 0) == ($267 | 0)) {
+ $294 = HEAP32[($mem + (($10 & -8) + 12) | 0) >> 2] | 0;
+ if (($294 | 0) == 0) {
+ $299 = HEAP32[($mem + (($10 & -8) + 8) | 0) >> 2] | 0;
+ if (($299 | 0) == 0) {
+ $R7_1 = 0;
+ break;
+ } else {
+ $R7_0 = $299;
+ $RP9_0 = $mem + (($10 & -8) + 8) | 0;
+ }
+ } else {
+ $R7_0 = $294;
+ $RP9_0 = $mem + (($10 & -8) + 12) | 0;
+ }
+ while (1) {
+ $301 = $R7_0 + 20 | 0;
+ $302 = HEAP32[$301 >> 2] | 0;
+ if (($302 | 0) != 0) {
+ $R7_0 = $302;
+ $RP9_0 = $301;
+ continue;
+ }
+ $305 = $R7_0 + 16 | 0;
+ $306 = HEAP32[$305 >> 2] | 0;
+ if (($306 | 0) == 0) {
+ break;
+ } else {
+ $R7_0 = $306;
+ $RP9_0 = $305;
+ }
+ }
+ if ($RP9_0 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[$RP9_0 >> 2] = 0;
+ $R7_1 = $R7_0;
+ break;
+ }
+ } else {
+ $278 = HEAP32[$mem + ($10 & -8) >> 2] | 0;
+ if ($278 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[($278 + 12 | 0) >> 2] | 0) != ($267 | 0)) {
+ _abort();
+ }
+ if ((HEAP32[($273 + 8 | 0) >> 2] | 0) == ($267 | 0)) {
+ HEAP32[($278 + 12 | 0) >> 2] = $273;
+ HEAP32[($273 + 8 | 0) >> 2] = $278;
+ $R7_1 = $273;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if (($270 | 0) == 0) {
+ break;
+ }
+ $320 = 384 + (HEAP32[($mem + (($10 & -8) + 20) | 0) >> 2] << 2) | 0;
+ do {
+ if (($267 | 0) == (HEAP32[$320 >> 2] | 0)) {
+ HEAP32[$320 >> 2] = $R7_1;
+ if (($R7_1 | 0) != 0) {
+ break;
+ }
+ HEAP32[21] = HEAP32[21] & (1 << HEAP32[($mem + (($10 & -8) + 20) | 0) >> 2] ^ -1);
+ break L726;
+ } else {
+ if ($270 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[($270 + 16 | 0) >> 2] | 0) == ($267 | 0)) {
+ HEAP32[($270 + 16 | 0) >> 2] = $R7_1;
+ } else {
+ HEAP32[$270 + 20 >> 2] = $R7_1;
+ }
+ if (($R7_1 | 0) == 0) {
+ break L726;
+ }
+ }
+ } while (0);
+ if ($R7_1 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[$R7_1 + 24 >> 2] = $270;
+ $351 = HEAP32[$mem + (($10 & -8) + 8) >> 2] | 0;
+ do {
+ if (($351 | 0) != 0) {
+ if ($351 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[$R7_1 + 16 >> 2] = $351;
+ HEAP32[$351 + 24 >> 2] = $R7_1;
+ break;
+ }
+ }
+ } while (0);
+ $364 = HEAP32[$mem + (($10 & -8) + 12) >> 2] | 0;
+ if (($364 | 0) == 0) {
+ break;
+ }
+ if ($364 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[$R7_1 + 20 >> 2] = $364;
+ HEAP32[$364 + 24 >> 2] = $R7_1;
+ break;
+ }
+ }
+ } while (0);
+ HEAP32[$p_0 + 4 >> 2] = $227 | 1;
+ HEAP32[$189 + $227 >> 2] = $227;
+ if (($p_0 | 0) != (HEAP32[25] | 0)) {
+ $psize_1 = $227;
+ break;
+ }
+ HEAP32[22] = $227;
+ return;
+ } else {
+ HEAP32[($mem + (($10 & -8) - 4) | 0) >> 2] = $194 & -2;
+ HEAP32[$p_0 + 4 >> 2] = $psize_0 | 1;
+ HEAP32[$189 + $psize_0 >> 2] = $psize_0;
+ $psize_1 = $psize_0;
+ }
+ } while (0);
+ $390 = $psize_1 >>> 3;
+ if ($psize_1 >>> 0 < 256) {
+ $396 = HEAP32[20] | 0;
+ do {
+ if (($396 & 1 << $390 | 0) == 0) {
+ HEAP32[20] = $396 | 1 << $390;
+ $F16_0 = 120 + ($390 << 1 << 2) | 0;
+ $_pre_phi = 120 + (($390 << 1) + 2 << 2) | 0;
+ } else {
+ $404 = HEAP32[(120 + (($390 << 1) + 2 << 2) | 0) >> 2] | 0;
+ if ($404 >>> 0 >= (HEAP32[24] | 0) >>> 0) {
+ $F16_0 = $404;
+ $_pre_phi = 120 + (($390 << 1) + 2 << 2) | 0;
+ break;
+ }
+ _abort();
+ }
+ } while (0);
+ HEAP32[$_pre_phi >> 2] = $p_0;
+ HEAP32[$F16_0 + 12 >> 2] = $p_0;
+ HEAP32[$p_0 + 8 >> 2] = $F16_0;
+ HEAP32[$p_0 + 12 >> 2] = 120 + ($390 << 1 << 2) | 0;
+ return;
+ }
+ $414 = $p_0;
+ $415 = $psize_1 >>> 8;
+ do {
+ if (($415 | 0) == 0) {
+ $I18_0 = 0;
+ } else {
+ if ($psize_1 >>> 0 > 16777215) {
+ $I18_0 = 31;
+ break;
+ }
+ $428 = $415 << (($415 + 1048320 | 0) >>> 16 & 8) << ((($415 << (($415 + 1048320 | 0) >>> 16 & 8)) + 520192 | 0) >>> 16 & 4);
+ $436 = 14 - ((($415 << (($415 + 1048320 | 0) >>> 16 & 8)) + 520192 | 0) >>> 16 & 4 | ($415 + 1048320 | 0) >>> 16 & 8 | ($428 + 245760 | 0) >>> 16 & 2) + ($428 << (($428 + 245760 | 0) >>> 16 & 2) >>> 15) | 0;
+ $I18_0 = $psize_1 >>> (($436 + 7 | 0) >>> 0) & 1 | $436 << 1;
+ }
+ } while (0);
+ $443 = 384 + ($I18_0 << 2) | 0;
+ HEAP32[$p_0 + 28 >> 2] = $I18_0;
+ HEAP32[$p_0 + 20 >> 2] = 0;
+ HEAP32[$p_0 + 16 >> 2] = 0;
+ $447 = HEAP32[21] | 0;
+ $448 = 1 << $I18_0;
+ do {
+ if (($447 & $448 | 0) == 0) {
+ HEAP32[21] = $447 | $448;
+ HEAP32[$443 >> 2] = $414;
+ HEAP32[$p_0 + 24 >> 2] = $443;
+ HEAP32[$p_0 + 12 >> 2] = $p_0;
+ HEAP32[$p_0 + 8 >> 2] = $p_0;
+ } else {
+ if (($I18_0 | 0) == 31) {
+ $463 = 0;
+ } else {
+ $463 = 25 - ($I18_0 >>> 1) | 0;
+ }
+ $K19_0 = $psize_1 << $463;
+ $T_0 = HEAP32[$443 >> 2] | 0;
+ while (1) {
+ if ((HEAP32[$T_0 + 4 >> 2] & -8 | 0) == ($psize_1 | 0)) {
+ break;
+ }
+ $472 = $T_0 + 16 + ($K19_0 >>> 31 << 2) | 0;
+ $473 = HEAP32[$472 >> 2] | 0;
+ if (($473 | 0) == 0) {
+ label = 569;
+ break;
+ } else {
+ $K19_0 = $K19_0 << 1;
+ $T_0 = $473;
+ }
+ }
+ if ((label | 0) == 569) {
+ if ($472 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[$472 >> 2] = $414;
+ HEAP32[$p_0 + 24 >> 2] = $T_0;
+ HEAP32[$p_0 + 12 >> 2] = $p_0;
+ HEAP32[$p_0 + 8 >> 2] = $p_0;
+ break;
+ }
+ }
+ $486 = $T_0 + 8 | 0;
+ $487 = HEAP32[$486 >> 2] | 0;
+ $489 = HEAP32[24] | 0;
+ if ($T_0 >>> 0 < $489 >>> 0) {
+ _abort();
+ }
+ if ($487 >>> 0 < $489 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[$487 + 12 >> 2] = $414;
+ HEAP32[$486 >> 2] = $414;
+ HEAP32[$p_0 + 8 >> 2] = $487;
+ HEAP32[$p_0 + 12 >> 2] = $T_0;
+ HEAP32[$p_0 + 24 >> 2] = 0;
+ break;
+ }
+ }
+ } while (0);
+ $501 = (HEAP32[28] | 0) - 1 | 0;
+ HEAP32[28] = $501;
+ if (($501 | 0) == 0) {
+ $sp_0_in_i = 536;
+ } else {
+ return;
+ }
+ while (1) {
+ $sp_0_i = HEAP32[$sp_0_in_i >> 2] | 0;
+ if (($sp_0_i | 0) == 0) {
+ break;
+ } else {
+ $sp_0_in_i = $sp_0_i + 8 | 0;
+ }
+ }
+ HEAP32[28] = -1;
+ return;
+}
+
diff --git a/tools/test-js-optimizer-asm-outline.js b/tools/test-js-optimizer-asm-outline.js
new file mode 100644
index 00000000..258bd522
--- /dev/null
+++ b/tools/test-js-optimizer-asm-outline.js
@@ -0,0 +1,566 @@
+function _free($mem) {
+ $mem = $mem | 0;
+ var $3 = 0, $4 = 0, $5 = 0, $10 = 0, $11 = 0, $14 = 0, $15 = 0, $16 = 0, $21 = 0, $_sum233 = 0, $24 = 0, $25 = 0, $26 = 0, $32 = 0, $37 = 0, $40 = 0, $43 = 0, $64 = 0, $_pre_phi307 = 0, $69 = 0, $72 = 0, $75 = 0, $80 = 0, $84 = 0, $88 = 0, $94 = 0, $95 = 0, $99 = 0, $100 = 0, $RP_0 = 0, $R_0 = 0, $102 = 0, $103 = 0, $106 = 0, $107 = 0, $R_1 = 0, $118 = 0, $120 = 0, $134 = 0, $151 = 0, $164 = 0, $177 = 0, $psize_0 = 0, $p_0 = 0, $189 = 0, $193 = 0, $194 = 0, $204 = 0, $220 = 0, $227 = 0, $228 = 0, $233 = 0, $236 = 0, $239 = 0, $262 = 0, $_pre_phi305 = 0, $267 = 0, $270 = 0, $273 = 0, $278 = 0, $283 = 0, $287 = 0, $293 = 0, $294 = 0, $298 = 0, $299 = 0, $RP9_0 = 0, $R7_0 = 0, $301 = 0, $302 = 0, $305 = 0, $306 = 0, $R7_1 = 0, $318 = 0, $320 = 0, $334 = 0, $351 = 0, $364 = 0, $psize_1 = 0, $390 = 0, $393 = 0, $395 = 0, $396 = 0, $397 = 0, $403 = 0, $404 = 0, $_pre_phi = 0, $F16_0 = 0, $414 = 0, $415 = 0, $422 = 0, $423 = 0, $426 = 0, $428 = 0, $431 = 0, $436 = 0, $I18_0 = 0, $443 = 0, $447 = 0, $448 = 0, $463 = 0, $T_0 = 0, $K19_0 = 0, $472 = 0, $473 = 0, $486 = 0, $487 = 0, $489 = 0, $501 = 0, $sp_0_in_i = 0, $sp_0_i = 0, label = 0;
+ if (($mem | 0) == 0) {
+ return;
+ }
+ $3 = $mem - 8 | 0;
+ $4 = $3;
+ $5 = HEAP32[24] | 0;
+ if ($3 >>> 0 < $5 >>> 0) {
+ _abort();
+ }
+ $10 = HEAP32[$mem - 4 >> 2] | 0;
+ $11 = $10 & 3;
+ if (($11 | 0) == 1) {
+ _abort();
+ }
+ $14 = $10 & -8;
+ $15 = $mem + ($14 - 8) | 0;
+ $16 = $15;
+ L621 : do {
+ if (($10 & 1 | 0) == 0) {
+ $21 = HEAP32[$3 >> 2] | 0;
+ if (($11 | 0) == 0) {
+ return;
+ }
+ $_sum233 = -8 - $21 | 0;
+ $24 = $mem + $_sum233 | 0;
+ $25 = $24;
+ $26 = $21 + $14 | 0;
+ if ($24 >>> 0 < $5 >>> 0) {
+ _abort();
+ }
+ if (($25 | 0) == (HEAP32[25] | 0)) {
+ $177 = $mem + ($14 - 4) | 0;
+ if ((HEAP32[$177 >> 2] & 3 | 0) != 3) {
+ $p_0 = $25;
+ $psize_0 = $26;
+ break;
+ }
+ HEAP32[22] = $26;
+ HEAP32[$177 >> 2] = HEAP32[$177 >> 2] & -2;
+ HEAP32[$mem + ($_sum233 + 4) >> 2] = $26 | 1;
+ HEAP32[$15 >> 2] = $26;
+ return;
+ }
+ $32 = $21 >>> 3;
+ if ($21 >>> 0 < 256) {
+ $37 = HEAP32[$mem + ($_sum233 + 8) >> 2] | 0;
+ $40 = HEAP32[$mem + ($_sum233 + 12) >> 2] | 0;
+ $43 = 120 + ($32 << 1 << 2) | 0;
+ do {
+ if (($37 | 0) != ($43 | 0)) {
+ if ($37 >>> 0 < $5 >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[$37 + 12 >> 2] | 0) == ($25 | 0)) {
+ break;
+ }
+ _abort();
+ }
+ } while (0);
+ if (($40 | 0) == ($37 | 0)) {
+ HEAP32[20] = HEAP32[20] & (1 << $32 ^ -1);
+ $p_0 = $25;
+ $psize_0 = $26;
+ break;
+ }
+ do {
+ if (($40 | 0) == ($43 | 0)) {
+ $_pre_phi307 = $40 + 8 | 0;
+ } else {
+ if ($40 >>> 0 < $5 >>> 0) {
+ _abort();
+ }
+ $64 = $40 + 8 | 0;
+ if ((HEAP32[$64 >> 2] | 0) == ($25 | 0)) {
+ $_pre_phi307 = $64;
+ break;
+ }
+ _abort();
+ }
+ } while (0);
+ HEAP32[$37 + 12 >> 2] = $40;
+ HEAP32[$_pre_phi307 >> 2] = $37;
+ $p_0 = $25;
+ $psize_0 = $26;
+ break;
+ }
+ $69 = $24;
+ $72 = HEAP32[$mem + ($_sum233 + 24) >> 2] | 0;
+ $75 = HEAP32[$mem + ($_sum233 + 12) >> 2] | 0;
+ do {
+ if (($75 | 0) == ($69 | 0)) {
+ $94 = $mem + ($_sum233 + 20) | 0;
+ $95 = HEAP32[$94 >> 2] | 0;
+ if (($95 | 0) == 0) {
+ $99 = $mem + ($_sum233 + 16) | 0;
+ $100 = HEAP32[$99 >> 2] | 0;
+ if (($100 | 0) == 0) {
+ $R_1 = 0;
+ break;
+ } else {
+ $R_0 = $100;
+ $RP_0 = $99;
+ }
+ } else {
+ $R_0 = $95;
+ $RP_0 = $94;
+ }
+ while (1) {
+ $102 = $R_0 + 20 | 0;
+ $103 = HEAP32[$102 >> 2] | 0;
+ if (($103 | 0) != 0) {
+ $R_0 = $103;
+ $RP_0 = $102;
+ continue;
+ }
+ $106 = $R_0 + 16 | 0;
+ $107 = HEAP32[$106 >> 2] | 0;
+ if (($107 | 0) == 0) {
+ break;
+ } else {
+ $R_0 = $107;
+ $RP_0 = $106;
+ }
+ }
+ if ($RP_0 >>> 0 < $5 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[$RP_0 >> 2] = 0;
+ $R_1 = $R_0;
+ break;
+ }
+ } else {
+ $80 = HEAP32[$mem + ($_sum233 + 8) >> 2] | 0;
+ if ($80 >>> 0 < $5 >>> 0) {
+ _abort();
+ }
+ $84 = $80 + 12 | 0;
+ if ((HEAP32[$84 >> 2] | 0) != ($69 | 0)) {
+ _abort();
+ }
+ $88 = $75 + 8 | 0;
+ if ((HEAP32[$88 >> 2] | 0) == ($69 | 0)) {
+ HEAP32[$84 >> 2] = $75;
+ HEAP32[$88 >> 2] = $80;
+ $R_1 = $75;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if (($72 | 0) == 0) {
+ $p_0 = $25;
+ $psize_0 = $26;
+ break;
+ }
+ $118 = $mem + ($_sum233 + 28) | 0;
+ $120 = 384 + (HEAP32[$118 >> 2] << 2) | 0;
+ do {
+ if (($69 | 0) == (HEAP32[$120 >> 2] | 0)) {
+ HEAP32[$120 >> 2] = $R_1;
+ if (($R_1 | 0) != 0) {
+ break;
+ }
+ HEAP32[21] = HEAP32[21] & (1 << HEAP32[$118 >> 2] ^ -1);
+ $p_0 = $25;
+ $psize_0 = $26;
+ break L621;
+ } else {
+ if ($72 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ }
+ $134 = $72 + 16 | 0;
+ if ((HEAP32[$134 >> 2] | 0) == ($69 | 0)) {
+ HEAP32[$134 >> 2] = $R_1;
+ } else {
+ HEAP32[$72 + 20 >> 2] = $R_1;
+ }
+ if (($R_1 | 0) == 0) {
+ $p_0 = $25;
+ $psize_0 = $26;
+ break L621;
+ }
+ }
+ } while (0);
+ if ($R_1 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[$R_1 + 24 >> 2] = $72;
+ $151 = HEAP32[$mem + ($_sum233 + 16) >> 2] | 0;
+ do {
+ if (($151 | 0) != 0) {
+ if ($151 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[$R_1 + 16 >> 2] = $151;
+ HEAP32[$151 + 24 >> 2] = $R_1;
+ break;
+ }
+ }
+ } while (0);
+ $164 = HEAP32[$mem + ($_sum233 + 20) >> 2] | 0;
+ if (($164 | 0) == 0) {
+ $p_0 = $25;
+ $psize_0 = $26;
+ break;
+ }
+ if ($164 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[$R_1 + 20 >> 2] = $164;
+ HEAP32[$164 + 24 >> 2] = $R_1;
+ $p_0 = $25;
+ $psize_0 = $26;
+ break;
+ }
+ } else {
+ $p_0 = $4;
+ $psize_0 = $14;
+ }
+ } while (0);
+ $189 = $p_0;
+ if ($189 >>> 0 >= $15 >>> 0) {
+ _abort();
+ }
+ $193 = $mem + ($14 - 4) | 0;
+ $194 = HEAP32[$193 >> 2] | 0;
+ if (($194 & 1 | 0) == 0) {
+ _abort();
+ }
+ do {
+ if (($194 & 2 | 0) == 0) {
+ if (($16 | 0) == (HEAP32[26] | 0)) {
+ $204 = (HEAP32[23] | 0) + $psize_0 | 0;
+ HEAP32[23] = $204;
+ HEAP32[26] = $p_0;
+ HEAP32[$p_0 + 4 >> 2] = $204 | 1;
+ if (($p_0 | 0) == (HEAP32[25] | 0)) {
+ HEAP32[25] = 0;
+ HEAP32[22] = 0;
+ }
+ if ($204 >>> 0 <= (HEAP32[27] | 0) >>> 0) {
+ return;
+ }
+ _sys_trim(0) | 0;
+ return;
+ }
+ if (($16 | 0) == (HEAP32[25] | 0)) {
+ $220 = (HEAP32[22] | 0) + $psize_0 | 0;
+ HEAP32[22] = $220;
+ HEAP32[25] = $p_0;
+ HEAP32[$p_0 + 4 >> 2] = $220 | 1;
+ HEAP32[$189 + $220 >> 2] = $220;
+ return;
+ }
+ $227 = ($194 & -8) + $psize_0 | 0;
+ $228 = $194 >>> 3;
+ L726 : do {
+ if ($194 >>> 0 < 256) {
+ $233 = HEAP32[$mem + $14 >> 2] | 0;
+ $236 = HEAP32[$mem + ($14 | 4) >> 2] | 0;
+ $239 = 120 + ($228 << 1 << 2) | 0;
+ do {
+ if (($233 | 0) != ($239 | 0)) {
+ if ($233 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[$233 + 12 >> 2] | 0) == ($16 | 0)) {
+ break;
+ }
+ _abort();
+ }
+ } while (0);
+ if (($236 | 0) == ($233 | 0)) {
+ HEAP32[20] = HEAP32[20] & (1 << $228 ^ -1);
+ break;
+ }
+ do {
+ if (($236 | 0) == ($239 | 0)) {
+ $_pre_phi305 = $236 + 8 | 0;
+ } else {
+ if ($236 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ }
+ $262 = $236 + 8 | 0;
+ if ((HEAP32[$262 >> 2] | 0) == ($16 | 0)) {
+ $_pre_phi305 = $262;
+ break;
+ }
+ _abort();
+ }
+ } while (0);
+ HEAP32[$233 + 12 >> 2] = $236;
+ HEAP32[$_pre_phi305 >> 2] = $233;
+ } else {
+ $267 = $15;
+ $270 = HEAP32[$mem + ($14 + 16) >> 2] | 0;
+ $273 = HEAP32[$mem + ($14 | 4) >> 2] | 0;
+ do {
+ if (($273 | 0) == ($267 | 0)) {
+ $293 = $mem + ($14 + 12) | 0;
+ $294 = HEAP32[$293 >> 2] | 0;
+ if (($294 | 0) == 0) {
+ $298 = $mem + ($14 + 8) | 0;
+ $299 = HEAP32[$298 >> 2] | 0;
+ if (($299 | 0) == 0) {
+ $R7_1 = 0;
+ break;
+ } else {
+ $R7_0 = $299;
+ $RP9_0 = $298;
+ }
+ } else {
+ $R7_0 = $294;
+ $RP9_0 = $293;
+ }
+ while (1) {
+ $301 = $R7_0 + 20 | 0;
+ $302 = HEAP32[$301 >> 2] | 0;
+ if (($302 | 0) != 0) {
+ $R7_0 = $302;
+ $RP9_0 = $301;
+ continue;
+ }
+ $305 = $R7_0 + 16 | 0;
+ $306 = HEAP32[$305 >> 2] | 0;
+ if (($306 | 0) == 0) {
+ break;
+ } else {
+ $R7_0 = $306;
+ $RP9_0 = $305;
+ }
+ }
+ if ($RP9_0 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[$RP9_0 >> 2] = 0;
+ $R7_1 = $R7_0;
+ break;
+ }
+ } else {
+ $278 = HEAP32[$mem + $14 >> 2] | 0;
+ if ($278 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ }
+ $283 = $278 + 12 | 0;
+ if ((HEAP32[$283 >> 2] | 0) != ($267 | 0)) {
+ _abort();
+ }
+ $287 = $273 + 8 | 0;
+ if ((HEAP32[$287 >> 2] | 0) == ($267 | 0)) {
+ HEAP32[$283 >> 2] = $273;
+ HEAP32[$287 >> 2] = $278;
+ $R7_1 = $273;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if (($270 | 0) == 0) {
+ break;
+ }
+ $318 = $mem + ($14 + 20) | 0;
+ $320 = 384 + (HEAP32[$318 >> 2] << 2) | 0;
+ do {
+ if (($267 | 0) == (HEAP32[$320 >> 2] | 0)) {
+ HEAP32[$320 >> 2] = $R7_1;
+ if (($R7_1 | 0) != 0) {
+ break;
+ }
+ HEAP32[21] = HEAP32[21] & (1 << HEAP32[$318 >> 2] ^ -1);
+ break L726;
+ } else {
+ if ($270 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ }
+ $334 = $270 + 16 | 0;
+ if ((HEAP32[$334 >> 2] | 0) == ($267 | 0)) {
+ HEAP32[$334 >> 2] = $R7_1;
+ } else {
+ HEAP32[$270 + 20 >> 2] = $R7_1;
+ }
+ if (($R7_1 | 0) == 0) {
+ break L726;
+ }
+ }
+ } while (0);
+ if ($R7_1 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[$R7_1 + 24 >> 2] = $270;
+ $351 = HEAP32[$mem + ($14 + 8) >> 2] | 0;
+ do {
+ if (($351 | 0) != 0) {
+ if ($351 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[$R7_1 + 16 >> 2] = $351;
+ HEAP32[$351 + 24 >> 2] = $R7_1;
+ break;
+ }
+ }
+ } while (0);
+ $364 = HEAP32[$mem + ($14 + 12) >> 2] | 0;
+ if (($364 | 0) == 0) {
+ break;
+ }
+ if ($364 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[$R7_1 + 20 >> 2] = $364;
+ HEAP32[$364 + 24 >> 2] = $R7_1;
+ break;
+ }
+ }
+ } while (0);
+ HEAP32[$p_0 + 4 >> 2] = $227 | 1;
+ HEAP32[$189 + $227 >> 2] = $227;
+ if (($p_0 | 0) != (HEAP32[25] | 0)) {
+ $psize_1 = $227;
+ break;
+ }
+ HEAP32[22] = $227;
+ return;
+ } else {
+ HEAP32[$193 >> 2] = $194 & -2;
+ HEAP32[$p_0 + 4 >> 2] = $psize_0 | 1;
+ HEAP32[$189 + $psize_0 >> 2] = $psize_0;
+ $psize_1 = $psize_0;
+ }
+ } while (0);
+ $390 = $psize_1 >>> 3;
+ if ($psize_1 >>> 0 < 256) {
+ $393 = $390 << 1;
+ $395 = 120 + ($393 << 2) | 0;
+ $396 = HEAP32[20] | 0;
+ $397 = 1 << $390;
+ do {
+ if (($396 & $397 | 0) == 0) {
+ HEAP32[20] = $396 | $397;
+ $F16_0 = $395;
+ $_pre_phi = 120 + ($393 + 2 << 2) | 0;
+ } else {
+ $403 = 120 + ($393 + 2 << 2) | 0;
+ $404 = HEAP32[$403 >> 2] | 0;
+ if ($404 >>> 0 >= (HEAP32[24] | 0) >>> 0) {
+ $F16_0 = $404;
+ $_pre_phi = $403;
+ break;
+ }
+ _abort();
+ }
+ } while (0);
+ HEAP32[$_pre_phi >> 2] = $p_0;
+ HEAP32[$F16_0 + 12 >> 2] = $p_0;
+ HEAP32[$p_0 + 8 >> 2] = $F16_0;
+ HEAP32[$p_0 + 12 >> 2] = $395;
+ return;
+ }
+ $414 = $p_0;
+ $415 = $psize_1 >>> 8;
+ do {
+ if (($415 | 0) == 0) {
+ $I18_0 = 0;
+ } else {
+ if ($psize_1 >>> 0 > 16777215) {
+ $I18_0 = 31;
+ break;
+ }
+ $422 = ($415 + 1048320 | 0) >>> 16 & 8;
+ $423 = $415 << $422;
+ $426 = ($423 + 520192 | 0) >>> 16 & 4;
+ $428 = $423 << $426;
+ $431 = ($428 + 245760 | 0) >>> 16 & 2;
+ $436 = 14 - ($426 | $422 | $431) + ($428 << $431 >>> 15) | 0;
+ $I18_0 = $psize_1 >>> (($436 + 7 | 0) >>> 0) & 1 | $436 << 1;
+ }
+ } while (0);
+ $443 = 384 + ($I18_0 << 2) | 0;
+ HEAP32[$p_0 + 28 >> 2] = $I18_0;
+ HEAP32[$p_0 + 20 >> 2] = 0;
+ HEAP32[$p_0 + 16 >> 2] = 0;
+ $447 = HEAP32[21] | 0;
+ $448 = 1 << $I18_0;
+ do {
+ if (($447 & $448 | 0) == 0) {
+ HEAP32[21] = $447 | $448;
+ HEAP32[$443 >> 2] = $414;
+ HEAP32[$p_0 + 24 >> 2] = $443;
+ HEAP32[$p_0 + 12 >> 2] = $p_0;
+ HEAP32[$p_0 + 8 >> 2] = $p_0;
+ } else {
+ if (($I18_0 | 0) == 31) {
+ $463 = 0;
+ } else {
+ $463 = 25 - ($I18_0 >>> 1) | 0;
+ }
+ $K19_0 = $psize_1 << $463;
+ $T_0 = HEAP32[$443 >> 2] | 0;
+ while (1) {
+ if ((HEAP32[$T_0 + 4 >> 2] & -8 | 0) == ($psize_1 | 0)) {
+ break;
+ }
+ $472 = $T_0 + 16 + ($K19_0 >>> 31 << 2) | 0;
+ $473 = HEAP32[$472 >> 2] | 0;
+ if (($473 | 0) == 0) {
+ label = 569;
+ break;
+ } else {
+ $K19_0 = $K19_0 << 1;
+ $T_0 = $473;
+ }
+ }
+ if ((label | 0) == 569) {
+ if ($472 >>> 0 < (HEAP32[24] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[$472 >> 2] = $414;
+ HEAP32[$p_0 + 24 >> 2] = $T_0;
+ HEAP32[$p_0 + 12 >> 2] = $p_0;
+ HEAP32[$p_0 + 8 >> 2] = $p_0;
+ break;
+ }
+ }
+ $486 = $T_0 + 8 | 0;
+ $487 = HEAP32[$486 >> 2] | 0;
+ $489 = HEAP32[24] | 0;
+ if ($T_0 >>> 0 < $489 >>> 0) {
+ _abort();
+ }
+ if ($487 >>> 0 < $489 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[$487 + 12 >> 2] = $414;
+ HEAP32[$486 >> 2] = $414;
+ HEAP32[$p_0 + 8 >> 2] = $487;
+ HEAP32[$p_0 + 12 >> 2] = $T_0;
+ HEAP32[$p_0 + 24 >> 2] = 0;
+ break;
+ }
+ }
+ } while (0);
+ $501 = (HEAP32[28] | 0) - 1 | 0;
+ HEAP32[28] = $501;
+ if (($501 | 0) == 0) {
+ $sp_0_in_i = 536;
+ } else {
+ return;
+ }
+ while (1) {
+ $sp_0_i = HEAP32[$sp_0_in_i >> 2] | 0;
+ if (($sp_0_i | 0) == 0) {
+ break;
+ } else {
+ $sp_0_in_i = $sp_0_i + 8 | 0;
+ }
+ }
+ HEAP32[28] = -1;
+ return;
+}
+// EMSCRIPTEN_GENERATED_FUNCTIONS
+// EXTRA_INFO: { "sizeToOutline": 1000 }