aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-01-14 20:53:53 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-01-14 20:54:14 -0800
commit60a86d0fcb15b8381f1fc97ad17571cb281f26c1 (patch)
tree1244fbd2f7ebbb404b503619fdf7477a89d737ba
parentb5ca47aee27b1dd86ad2623c4591019ad0be97ea (diff)
fix aggressiveVariableElimination bug and add testing
-rw-r--r--tests/test_other.py2
-rw-r--r--tools/js-optimizer.js4
-rw-r--r--tools/test-js-optimizer-shiftsAggressive-output.js11
-rw-r--r--tools/test-js-optimizer-shiftsAggressive.js13
4 files changed, 28 insertions, 2 deletions
diff --git a/tests/test_other.py b/tests/test_other.py
index f91b4683..00c42418 100644
--- a/tests/test_other.py
+++ b/tests/test_other.py
@@ -1736,6 +1736,8 @@ f.close()
['asm', 'outline']),
(path_from_root('tools', 'test-js-optimizer-asm-minlast.js'), open(path_from_root('tools', 'test-js-optimizer-asm-minlast-output.js')).read(),
['asm', 'minifyWhitespace', 'last']),
+ (path_from_root('tools', 'test-js-optimizer-shiftsAggressive.js'), open(path_from_root('tools', 'test-js-optimizer-shiftsAggressive-output.js')).read(),
+ ['asm', 'aggressiveVariableElimination']),
]:
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 5324e15c..3a6d70bc 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -3117,8 +3117,8 @@ function aggressiveVariableEliminationInternal(func, asmData) {
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
+ if (value) return copy(value); // must copy, or else the same object can be used multiple times
+ else return emptyNode();
}
}
});
diff --git a/tools/test-js-optimizer-shiftsAggressive-output.js b/tools/test-js-optimizer-shiftsAggressive-output.js
new file mode 100644
index 00000000..5b429786
--- /dev/null
+++ b/tools/test-js-optimizer-shiftsAggressive-output.js
@@ -0,0 +1,11 @@
+function __ZNSt3__111__call_onceERVmPvPFvS2_E($flag, $arg, $func) {
+ $flag = $flag | 0;
+ $arg = $arg | 0;
+ $func = $func | 0;
+ var $2 = 0;
+ $2 = cheez();
+ whee1($flag + 1 | 0);
+ whee2($flag + 1 | 0);
+ whee3($flag + 1 | 0);
+}
+
diff --git a/tools/test-js-optimizer-shiftsAggressive.js b/tools/test-js-optimizer-shiftsAggressive.js
new file mode 100644
index 00000000..4218d04c
--- /dev/null
+++ b/tools/test-js-optimizer-shiftsAggressive.js
@@ -0,0 +1,13 @@
+function __ZNSt3__111__call_onceERVmPvPFvS2_E($flag,$arg,$func){
+ $flag=($flag)|0;
+ $arg=($arg)|0;
+ $func=($func)|0;
+ var $1=0,$2=0,$3=0;
+ $1;
+ $2 = cheez();
+ $3 = $flag + 1 | 0;
+ whee1($3);
+ whee2($3);
+ whee3($3);
+}
+// EMSCRIPTEN_GENERATED_FUNCTIONS: ["__ZNSt3__111__call_onceERVmPvPFvS2_E"]