diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-11-08 18:26:19 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-11-08 18:26:19 -0800 |
commit | 1b0215b9bd69bc6faf4a1843e7e01a1fb59e6fc3 (patch) | |
tree | 9906da1fd3e0526b0dc6fe388fc1f4bee6a194c8 | |
parent | dbd5252e191327b6ccdb5e3b4d34522b35bbea8e (diff) |
rename __label__ => label
-rw-r--r-- | src/jsifier.js | 14 | ||||
-rw-r--r-- | src/library.js | 2 | ||||
-rw-r--r-- | tools/js-optimizer.js | 22 | ||||
-rw-r--r-- | tools/test-js-optimizer-output.js | 28 | ||||
-rw-r--r-- | tools/test-js-optimizer-regs.js | 2 | ||||
-rw-r--r-- | tools/test-js-optimizer-t3.js | 20 | ||||
-rw-r--r-- | tools/test-js-optimizer.js | 144 |
7 files changed, 116 insertions, 116 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index bfa1b579..8fcac49c 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -567,7 +567,7 @@ function JSify(data, functionsOnly, givenFunctions) { if (true) { // TODO: optimize away when not needed if (CLOSURE_ANNOTATIONS) func.JS += '/** @type {number} */'; - func.JS += ' var __label__;\n'; + func.JS += ' var label;\n'; } // Walk function blocks and generate JS @@ -601,13 +601,13 @@ function JSify(data, functionsOnly, givenFunctions) { if (!RELOOP) { if (block.labels.length > 1) { if (block.entries.length == 1) { - ret += indent + '__label__ = ' + getLabelId(block.entries[0]) + '; ' + (SHOW_LABELS ? '/* ' + getOriginalLabelId(block.entries[0]) + ' */' : '') + '\n'; + ret += indent + 'label = ' + getLabelId(block.entries[0]) + '; ' + (SHOW_LABELS ? '/* ' + getOriginalLabelId(block.entries[0]) + ' */' : '') + '\n'; } // otherwise, should have been set before! if (func.setjmpTable) { var setjmpTable = {}; ret += indent + 'var setjmpTable = {'; func.setjmpTable.forEach(function(triple) { // original label, label we created for right after the setjmp, variable setjmp result goes into - ret += '"' + getLabelId(triple[0]) + '": ' + 'function(value) { __label__ = ' + getLabelId(triple[1]) + '; ' + triple[2] + ' = value },'; + ret += '"' + getLabelId(triple[0]) + '": ' + 'function(value) { label = ' + getLabelId(triple[1]) + '; ' + triple[2] + ' = value },'; }); ret += 'dummy: 0'; ret += '};\n'; @@ -616,12 +616,12 @@ function JSify(data, functionsOnly, givenFunctions) { if (func.setjmpTable) { ret += 'try { '; } - ret += 'switch(__label__) {\n'; + ret += 'switch(label) {\n'; ret += block.labels.map(function(label) { return indent + ' case ' + getLabelId(label.ident) + ': ' + (SHOW_LABELS ? '// ' + getOriginalLabelId(label.ident) : '') + '\n' + getLabelLines(label, indent + ' '); }).join('\n'); - ret += '\n' + indent + ' default: assert(0, "bad label: " + __label__);\n' + indent + '}'; + ret += '\n' + indent + ' default: assert(0, "bad label: " + label);\n' + indent + '}'; if (func.setjmpTable) { ret += ' } catch(e) { if (!e.longjmp) throw(e); setjmpTable[e.label](e.value) }'; } @@ -828,7 +828,7 @@ function JSify(data, functionsOnly, givenFunctions) { var parts = label.split('|'); var trueLabel = parts[1] || ''; var oldLabel = parts[2] || ''; - var labelSetting = oldLabel ? '__label__ = ' + getLabelId(oldLabel) + ';' + + var labelSetting = oldLabel ? 'label = ' + getLabelId(oldLabel) + ';' + (SHOW_LABELS ? ' /* to: ' + getOriginalLabelId(cleanLabel(oldLabel)) + ' */' : '') : ''; // TODO: optimize away the setting if (label[1] == 'R') { if (label[2] == 'N') { // BRNOL: break, no label setting @@ -849,7 +849,7 @@ function JSify(data, functionsOnly, givenFunctions) { } } else { if (!labelIsVariable) label = getLabelId(label); - return pre + '__label__ = ' + label + ';' + (SHOW_LABELS ? ' /* to: ' + getOriginalLabelId(cleanLabel(label)) + ' */' : '') + ' break;'; + return pre + 'label = ' + label + ';' + (SHOW_LABELS ? ' /* to: ' + getOriginalLabelId(cleanLabel(label)) + ' */' : '') + ' break;'; } } diff --git a/src/library.js b/src/library.js index c7fe9fcb..fd5e0fae 100644 --- a/src/library.js +++ b/src/library.js @@ -5841,7 +5841,7 @@ LibraryManager.library = { setjmp__inline: function(env) { // Save the label - return '(' + makeSetValue(env, '0', '__label__', 'i32') + ', 0)'; + return '(' + makeSetValue(env, '0', 'label', 'i32') + ', 0)'; }, longjmp: function(env, value) { diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 6c0a8151..aedda961 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -371,8 +371,8 @@ function removeAssignsToUndefined(ast) { } // XXX This is an invalid optimization -// We sometimes leave some settings to __label__ that are not needed, if later in -// the relooper we realize that we have a single entry, so no checks on __label__ +// We sometimes leave some settings to label that are not needed, if later in +// the relooper we realize that we have a single entry, so no checks on label // are actually necessary. It's easy to clean those up now. function removeUnneededLabelSettings(ast) { traverse(ast, function(node, type) { @@ -380,14 +380,14 @@ function removeUnneededLabelSettings(ast) { // Find all checks var checked = {}; traverse(node, function(node, type) { - if (type == 'binary' && node[1] == '==' && node[2][0] == 'name' && node[2][1] == '__label__') { + if (type == 'binary' && node[1] == '==' && node[2][0] == 'name' && node[2][1] == 'label') { assert(node[3][0] == 'num'); checked[node[3][1]] = 1; } }); // Remove unneeded sets traverse(node, function(node, type) { - if (type == 'assign' && node[2][0] == 'name' && node[2][1] == '__label__') { + if (type == 'assign' && node[2][0] == 'name' && node[2][1] == 'label') { assert(node[3][0] == 'num'); if (!(node[3][1] in checked)) return emptyNode(); } @@ -954,9 +954,9 @@ function getStatements(node) { } // Multiple blocks from the relooper are, in general, implemented by -// if (__label__ == x) { } else if .. +// if (label == x) { } else if .. // and branching into them by -// if (condition) { __label__ == x } else .. +// if (condition) { label == x } else .. // We can hoist the multiple block into the condition, thus removing code and one 'if' check function hoistMultiples(ast) { traverseGeneratedFunctions(ast, function(node) { @@ -987,7 +987,7 @@ function hoistMultiples(ast) { // Look into this if, and its elseifs while (postInner && postInner[0] == 'if') { var cond = postInner[1]; - if (cond[0] == 'binary' && cond[1] == '==' && cond[2][0] == 'name' && cond[2][1] == '__label__') { + if (cond[0] == 'binary' && cond[1] == '==' && cond[2][0] == 'name' && cond[2][1] == 'label') { assert(cond[3][0] == 'num'); // We have a valid Multiple check here. Try to hoist it, look for the source in |pre| and its else's var labelNum = cond[3][1]; @@ -995,10 +995,10 @@ function hoistMultiples(ast) { assert(labelBlock[0] == 'block'); var found = false; traverse(pre, function(preNode, preType) { - if (!found && preType == 'assign' && preNode[2][0] == 'name' && preNode[2][1] == '__label__') { + if (!found && preType == 'assign' && preNode[2][0] == 'name' && preNode[2][1] == 'label') { assert(preNode[3][0] == 'num'); if (preNode[3][1] == labelNum) { - // That's it! Hoist away. We can also throw away the __label__ setting as its goal has already been achieved + // That's it! Hoist away. We can also throw away the label setting as its goal has already been achieved found = true; modifiedI = true; postInner[2] = ['block', []]; @@ -1021,7 +1021,7 @@ function hoistMultiples(ast) { if (modified) return node; }); - // After hoisting in this function, it is safe to remove { __label__ = x; } blocks, because + // After hoisting in this function, it is safe to remove { label = x; } blocks, because // if they were leading to the next code right after them, they would be hoisted, and if they // are going to some other place entirely, they would break or continue. The only risky // situation is if the code after us is a multiple, in which case we might be checking for @@ -1035,7 +1035,7 @@ function hoistMultiples(ast) { if (node[0] == 'block' && node[1] && node[1].length > 0) { var subNode = node[1][node[1].length-1]; if (subNode[0] == 'stat' && subNode[1][0] == 'assign' && subNode[1][2][0] == 'name' && - subNode[1][2][1] == '__label__' && subNode[1][3][0] == 'num') { + subNode[1][2][1] == 'label' && subNode[1][3][0] == 'num') { if (node[1].length == 1) { return emptyNode(); } else { diff --git a/tools/test-js-optimizer-output.js b/tools/test-js-optimizer-output.js index b9465d73..9c9fa063 100644 --- a/tools/test-js-optimizer-output.js +++ b/tools/test-js-optimizer-output.js @@ -91,11 +91,11 @@ function hoisting() { } pause(5); if ($i < $N) { - __label__ = 2; + label = 2; } else { somethingElse(); } - if (__label__ == 55) { + if (label == 55) { callOther(); } pause(6); @@ -105,7 +105,7 @@ function hoisting() { pause(7); while (1) { if ($i >= $N) { - __label__ = 3; + label = 3; break; } somethingElse(); @@ -119,19 +119,19 @@ function hoisting() { do { if ($cmp95) { if (!$cmp103) { - __label__ = 38; + label = 38; break; } if (!$cmp106) { - __label__ = 38; + label = 38; break; } - __label__ = 39; + label = 39; break; } - __label__ = 38; + label = 38; } while (0); - if (__label__ == 38) { + if (label == 38) { var $79 = $_pr6; } pause(9); @@ -200,15 +200,15 @@ function demangle($cmp) { do { if (!$cmp) { if (something()) { - __label__ = 3; + label = 3; break; } more(); break; } - __label__ = 3; + label = 3; } while (0); - if (__label__ == 3) { + if (label == 3) { final(); } } @@ -229,15 +229,15 @@ function lua() { } pause(); if ($1435 == 0) { - __label__ = 176; + label = 176; cheez(); } else if ($1435 != 1) { - __label__ = 180; + label = 180; cheez(); } pause(); if ($1435 == 0) { - __label__ = 176; + label = 176; cheez(); } } diff --git a/tools/test-js-optimizer-regs.js b/tools/test-js-optimizer-regs.js index 2aa95b74..4802afa3 100644 --- a/tools/test-js-optimizer-regs.js +++ b/tools/test-js-optimizer-regs.js @@ -24,7 +24,7 @@ function test() { f(ck()); } function primes() { - var __label__; + var label; var $curri_01 = 2; var $primes_02 = 0; $_$2 : while (1) { diff --git a/tools/test-js-optimizer-t3.js b/tools/test-js-optimizer-t3.js index 489f0329..5519189f 100644 --- a/tools/test-js-optimizer-t3.js +++ b/tools/test-js-optimizer-t3.js @@ -1,30 +1,30 @@ function _png_create_write_struct_2($user_png_ver, $error_ptr, $error_fn, $warn_fn, $mem_ptr, $malloc_fn, $free_fn) { var $png_ptr$s2; - var __label__; - __label__ = 2; + var label; + label = 2; var setjmpTable = { "2": (function(value) { - __label__ = 5; + label = 5; $call1 = value; }), dummy: 0 }; while (1) try { - switch (__label__) { + switch (label) { case 2: var $png_ptr; var $call = _png_create_struct(1); $png_ptr = $call; - var $call1 = (HEAP32[$png_ptr >> 2] = __label__, 0); - __label__ = 5; + var $call1 = (HEAP32[$png_ptr >> 2] = label, 0); + label = 5; break; case 5: var $2 = $png_ptr; if (($call1 | 0) == 0) { - __label__ = 4; + label = 4; break; } else { - __label__ = 3; + label = 3; break; } case 3: @@ -33,13 +33,13 @@ function _png_create_write_struct_2($user_png_ver, $error_ptr, $error_fn, $warn_ HEAP32[($png_ptr >> 2) + (148 >> 2)] = 0; _png_destroy_struct($png_ptr); var $retval_0 = 0; - __label__ = 4; + label = 4; break; case 4: var $retval_0; return $retval_0; default: - assert(0, "bad label: " + __label__); + assert(0, "bad label: " + label); } } catch (e) { if (!e.longjmp) throw e; diff --git a/tools/test-js-optimizer.js b/tools/test-js-optimizer.js index 7707b1dc..dc48575c 100644 --- a/tools/test-js-optimizer.js +++ b/tools/test-js-optimizer.js @@ -64,91 +64,91 @@ function maths() { } function hoisting() { if ($i < $N) { - __label__ = 2; + label = 2; } - if (__label__ == 2) { + if (label == 2) { callOther(); } pause(1); if ($i < $N) { - __label__ = 2; + label = 2; } else { - __label__ = 3; + label = 3; } $for_body3$$for_end$5 : do { - if (__label__ == 2) { + if (label == 2) { while(true) { break $for_body3$$for_end$5 } callOther(); } } while (0); pause(2); if ($i < $N) { - __label__ = 2; + label = 2; } else { - __label__ = 3; + label = 3; } cheez: do { - if (__label__ == 2) { + if (label == 2) { if (callOther()) break cheez; } } while (0); pause(3); if ($i < $N) { - __label__ = 2; + label = 2; } else { - __label__ = 3; + label = 3; } - if (__label__ == 2) { + if (label == 2) { callOther(); } pause(4); if ($i < $N) { - __label__ = 2; + label = 2; } else { - __label__ = 3; + label = 3; } - if (__label__ == 2) { + if (label == 2) { callOther(); - } else if (__label__ == 3) { + } else if (label == 3) { somethingElse(); } pause(5); if ($i < $N) { - __label__ = 2; + label = 2; } else { - __label__ = 3; + label = 3; } - if (__label__ == 55) { + if (label == 55) { callOther(); - } else if (__label__ == 3) { + } else if (label == 3) { somethingElse(); } pause(6); if ($i < $N) { - __label__ = 2; + label = 2; } else { - __label__ = 3; + label = 3; } - if (__label__ == 3) { + if (label == 3) { somethingElse(); } pause(7); free: while (1) { if ($i < $N) { - __label__ = 2; + label = 2; } else { - __label__ = 3; // this cannot be removed! + label = 3; // this cannot be removed! break; } - if (__label__ == 2) { + if (label == 2) { somethingElse(); } if ($i < $N) { - __label__ = 2; + label = 2; } else { - __label__ = 3; // this can be removed! + label = 3; // this can be removed! } - if (__label__ == 2) { + if (label == 2) { somethingElse(); } nothing(); @@ -156,94 +156,94 @@ function hoisting() { pause(8); var $cmp95 = $69 == -1; if ($cmp95) { - __label__ = 35; + label = 35; } else { - __label__ = 38; + label = 38; } $if_then96$$if_end110thread_pre_split$48 : do { - if (__label__ == 35) { + if (label == 35) { if (!$cmp103) { - __label__ = 38; + label = 38; break $if_then96$$if_end110thread_pre_split$48; } if (!$cmp106) { - __label__ = 38; + label = 38; break $if_then96$$if_end110thread_pre_split$48; } - __label__ = 39; + label = 39; break $if_then96$$if_end110thread_pre_split$48; } } while (0); $if_end110$$if_end110thread_pre_split$52 : do { - if (__label__ == 38) { + if (label == 38) { var $79 = $_pr6; } } while (0); pause(9); var $cmp70 = ($call69 | 0) != 0; if ($cmp70) { - __label__ = 40; + label = 40; } else { - __label__ = 41; + label = 41; } $if_then72$$if_end73$126 : do { - if (__label__ == 40) {} else if (__label__ == 41) {} + if (label == 40) {} else if (label == 41) {} } while (0); pause(10); while(check()) { if ($i < $N) { - __label__ = 2; + label = 2; } else { - __label__ = 3; + label = 3; } - if (__label__ == 2) { + if (label == 2) { callOther(); break; - } else if (__label__ == 3) { + } else if (label == 3) { somethingElse(); } if ($i1 < $N) { - __label__ = 2; + label = 2; } else { - __label__ = 3; + label = 3; } - if (__label__ == 2) { + if (label == 2) { callOther(); continue; - } else if (__label__ == 3) { + } else if (label == 3) { somethingElse(); } if ($i2 < $N) { - __label__ = 2; + label = 2; } else { - __label__ = 3; + label = 3; } - if (__label__ == 2) { + if (label == 2) { callOther(); - } else if (__label__ == 3) { + } else if (label == 3) { somethingElse(); break; } if ($i3 < $N) { - __label__ = 2; + label = 2; } else { - __label__ = 3; + label = 3; } - if (__label__ == 2) { + if (label == 2) { callOther(); - } else if (__label__ == 3) { + } else if (label == 3) { somethingElse(); continue; } if ($i4 < $N) { - __label__ = 2; + label = 2; } else { - __label__ = 3; + label = 3; } - if (__label__ == 2) { + if (label == 2) { callOther(); break; - } else if (__label__ == 3) { + } else if (label == 3) { somethingElse(); continue; } @@ -252,9 +252,9 @@ function hoisting() { function innerShouldAlsoBeHoisted() { function hoisting() { if ($i < $N) { - __label__ = 2; + label = 2; } - if (__label__ == 2) { + if (label == 2) { callOther(); } } @@ -288,14 +288,14 @@ function sleep() { } function demangle($cmp) { if ($cmp) { - __label__ = 3; + label = 3; } else { - __label__ = 1; + label = 1; } $if_then$$lor_lhs_false$2 : do { - if (__label__ == 1) { + if (label == 1) { if (something()) { - __label__ = 3; + label = 3; break $if_then$$lor_lhs_false$2; } more(); @@ -303,7 +303,7 @@ function demangle($cmp) { } } while (0); $if_then$$return$6 : do { - if (__label__ == 3) { + if (label == 3) { final(); } } while (0); @@ -311,12 +311,12 @@ function demangle($cmp) { function lua() { $5$98 : while (1) { if ($14) { - __label__ = 3; + label = 3; } else { - __label__ = 4; + label = 4; } $15$$16$101 : do { - if (__label__ == 3) {} else if (__label__ == 4) { + if (label == 3) {} else if (label == 4) { var $17 = $i; var $18 = $3; var $19 = $18 + ($17 << 2) | 0; @@ -330,15 +330,15 @@ function lua() { } pause(); if ($1435 == 0) { - __label__ = 176; + label = 176; cheez(); } else if ($1435 == 1) {} else { - __label__ = 180; + label = 180; cheez(); } pause(); if ($1435 == 0) { - __label__ = 176; + label = 176; cheez(); } else if ($1435 == 1) {} } @@ -374,7 +374,7 @@ function moreLabels() { } } else { var $_lcssa = $5; - __label__ = 2; + label = 2; } } while (0); var $_lcssa; |