aboutsummaryrefslogtreecommitdiff
path: root/tools/js-optimizer.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-03-09 20:22:33 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-03-09 20:22:33 -0800
commitb5c3e1bda0ef9080228f452ce7ca8c60d3dcf452 (patch)
tree5a3f7d515a29be506edfd2beb0a4d391ab6faa0b /tools/js-optimizer.js
parent0f538ae57bb65af11efb7372661ba7c929c98d61 (diff)
remove coercions on asm function calls that have no capturing variables
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r--tools/js-optimizer.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 834c99e3..48ab5a1f 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -540,12 +540,20 @@ function simplifyExpressionsPre(ast) {
});
}
- function addFinalReturns(ast) {
+ function asmOpts(ast) {
+ // 1. Add final returns when necessary
+ // 2. Remove unneeded coercions on function calls that have no targets (eliminator removed it)
traverseGeneratedFunctions(ast, function(fun) {
var returnType = null;
traverse(fun, function(node, type) {
if (type == 'return' && node[1]) {
returnType = detectAsmCoercion(node[1]);
+ } else if (type == 'stat') {
+ var inner = node[1];
+ if ((inner[0] == 'binary' && inner[1] in ASSOCIATIVE_BINARIES && inner[2][0] == 'call' && inner[3][0] == 'num') ||
+ (inner[0] == 'unary-prefix' && inner[1] == '+' && inner[2][0] == 'call')) {
+ node[1] = inner[2];
+ }
}
});
// Add a final return if one is missing.
@@ -564,7 +572,7 @@ function simplifyExpressionsPre(ast) {
simplifyBitops(ast);
joinAdditions(ast);
// simplifyZeroComp(ast); TODO: investigate performance
- if (asm) addFinalReturns(ast);
+ if (asm) asmOpts(ast);
}
// In typed arrays mode 2, we can have