aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js26
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 8360473f..216aade9 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -111,6 +111,7 @@ merge(Compressor.prototype, {
node.DEFMETHOD("optimize", function(compressor){
var self = this;
if (self._optimized) return self;
+ if (compressor.has_directive("use asm")) return self;
var opt = optimizer(self, compressor);
opt._optimized = true;
if (opt === self) return opt;
@@ -1026,6 +1027,7 @@ merge(Compressor.prototype, {
AST_Scope.DEFMETHOD("drop_unused", function(compressor){
var self = this;
+ if (compressor.has_directive("use asm")) return self;
if (compressor.option("unused")
&& !(self instanceof AST_Toplevel)
&& !self.uses_eval
@@ -1205,9 +1207,10 @@ merge(Compressor.prototype, {
});
AST_Scope.DEFMETHOD("hoist_declarations", function(compressor){
+ var self = this;
+ if (compressor.has_directive("use asm")) return self;
var hoist_funs = compressor.option("hoist_funs");
var hoist_vars = compressor.option("hoist_vars");
- var self = this;
if (hoist_funs || hoist_vars) {
var dirs = [];
var hoisted = [];
@@ -2028,15 +2031,14 @@ merge(Compressor.prototype, {
var commutativeOperators = makePredicate("== === != !== * & | ^");
OPT(AST_Binary, function(self, compressor){
- var reverse = compressor.has_directive("use asm") ? noop
- : function(op, force) {
- if (force || !(self.left.has_side_effects(compressor) || self.right.has_side_effects(compressor))) {
- if (op) self.operator = op;
- var tmp = self.left;
- self.left = self.right;
- self.right = tmp;
- }
- };
+ function reverse(op, force) {
+ if (force || !(self.left.has_side_effects(compressor) || self.right.has_side_effects(compressor))) {
+ if (op) self.operator = op;
+ var tmp = self.left;
+ self.left = self.right;
+ self.right = tmp;
+ }
+ }
if (commutativeOperators(self.operator)) {
if (self.right instanceof AST_Constant
&& !(self.left instanceof AST_Constant)) {
@@ -2104,10 +2106,10 @@ merge(Compressor.prototype, {
if (compressor.option("conditionals")) {
if (self.operator == "&&") {
var ll = self.left.evaluate(compressor);
- var rr = self.right.evaluate(compressor);
if (ll.length > 1) {
if (ll[1]) {
compressor.warn("Condition left of && always true [{file}:{line},{col}]", self.start);
+ var rr = self.right.evaluate(compressor);
return rr[0];
} else {
compressor.warn("Condition left of && always false [{file}:{line},{col}]", self.start);
@@ -2117,13 +2119,13 @@ merge(Compressor.prototype, {
}
else if (self.operator == "||") {
var ll = self.left.evaluate(compressor);
- var rr = self.right.evaluate(compressor);
if (ll.length > 1) {
if (ll[1]) {
compressor.warn("Condition left of || always true [{file}:{line},{col}]", self.start);
return ll[0];
} else {
compressor.warn("Condition left of || always false [{file}:{line},{col}]", self.start);
+ var rr = self.right.evaluate(compressor);
return rr[0];
}
}