Don't swap binary ops when "use asm" is in effect.

Refs #167
This commit is contained in:
Mihai Bazon
2013-06-07 12:51:23 +03:00
parent a4889a0f2e
commit 02a84385a0
2 changed files with 12 additions and 8 deletions

View File

@@ -945,6 +945,9 @@ TreeWalker.prototype = {
if (x instanceof type) return x; if (x instanceof type) return x;
} }
}, },
has_directive: function(type) {
return this.find_parent(AST_Scope).has_directive(type);
},
in_boolean_context: function() { in_boolean_context: function() {
var stack = this.stack; var stack = this.stack;
var i = stack.length, self = stack[--i]; var i = stack.length, self = stack[--i];

View File

@@ -1765,7 +1765,8 @@ merge(Compressor.prototype, {
var commutativeOperators = makePredicate("== === != !== * & | ^"); var commutativeOperators = makePredicate("== === != !== * & | ^");
OPT(AST_Binary, function(self, compressor){ OPT(AST_Binary, function(self, compressor){
function reverse(op, force) { var reverse = compressor.has_directive("use asm") ? noop
: function(op, force) {
if (force || !(self.left.has_side_effects() || self.right.has_side_effects())) { if (force || !(self.left.has_side_effects() || self.right.has_side_effects())) {
if (op) self.operator = op; if (op) self.operator = op;
var tmp = self.left; var tmp = self.left;