aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-05-25 16:05:17 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-05-25 16:05:17 -0700
commit7011aa3831041920d5269d873b0c16acaa042360 (patch)
tree69d9182003df77fa329c0ff6e6cb628cbc3effd8 /tools
parent83bd24902870514c2abcc3a9aa5261c85b7d1fb7 (diff)
registerize in asm switches
Diffstat (limited to 'tools')
-rw-r--r--tools/js-optimizer.js4
-rw-r--r--tools/test-js-optimizer-asm-regs-output.js14
2 files changed, 9 insertions, 9 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 4b0938c2..a52ad6b7 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -1505,7 +1505,7 @@ function registerize(ast) {
// Replace all var definitions with assignments; we will add var definitions at the top after we registerize
// We also mark local variables - i.e., having a var definition
var localVars = {};
- var hasSwitch = false; // we cannot optimize variables if there is a switch
+ var hasSwitch = false; // we cannot optimize variables if there is a switch, unless in asm mode
traverse(fun, function(node, type) {
if (type == 'var') {
node[1].forEach(function(defined) { localVars[defined[0]] = 1 });
@@ -1630,7 +1630,7 @@ function registerize(ast) {
}
});
var optimizables = {};
- if (!hasSwitch) {
+ if (!hasSwitch || asm) {
for (var possible in possibles) {
if (!unoptimizables[possible]) optimizables[possible] = 1;
}
diff --git a/tools/test-js-optimizer-asm-regs-output.js b/tools/test-js-optimizer-asm-regs-output.js
index 71155410..ba2316ea 100644
--- a/tools/test-js-optimizer-asm-regs-output.js
+++ b/tools/test-js-optimizer-asm-regs-output.js
@@ -25,15 +25,15 @@ function stackRestore(i1) {
function switchey(d1, i2) {
d1 = +d1;
i2 = i2 | 0;
- var i3 = 0, d4 = +0, i5 = 0, d6 = +0;
+ var i3 = 0, d4 = +0;
switch (d1 | 0) {
case 0:
- i3 = d1 + d1 | 0;
- d4 = d(Math_max(10, Math_min(5, f())));
- i5 = i3 + 2 | 0;
- print(i5);
- d6 = d4 * 5;
- return d6;
+ i2 = d1 + d1 | 0;
+ d1 = d(Math_max(10, Math_min(5, f())));
+ i3 = i2 + 2 | 0;
+ print(i3);
+ d4 = d1 * 5;
+ return d4;
case 1:
return 20;
}