Asm.js: bypass any compression transformations exept drop_unused
This commit is contained in:
parent
b91dca87ee
commit
fa69efa0c8
|
|
@ -89,13 +89,15 @@ merge(Compressor.prototype, {
|
|||
},
|
||||
before: function(node, descend, in_list) {
|
||||
if (node._squeezed) return node;
|
||||
var was_scope = false;
|
||||
// asm.js: drop unused only, leave everything else as is inside "use asm" scope
|
||||
var asm = this.has_directive("use asm"),
|
||||
was_scope = false;
|
||||
if (node instanceof AST_Scope) {
|
||||
node = node.hoist_declarations(this);
|
||||
if (!asm) node = node.hoist_declarations(this);
|
||||
was_scope = true;
|
||||
}
|
||||
descend(node, this);
|
||||
node = node.optimize(this);
|
||||
if (!asm) node = node.optimize(this);
|
||||
if (was_scope && node instanceof AST_Scope) {
|
||||
node.drop_unused(this);
|
||||
descend(node, this);
|
||||
|
|
@ -893,6 +895,15 @@ merge(Compressor.prototype, {
|
|||
def(AST_Constant, function(compressor){ return false });
|
||||
def(AST_This, function(compressor){ return false });
|
||||
|
||||
// asm.js: `new stdlib.XYZ` inside "use asm" scope are always pure
|
||||
def(AST_New, function(compressor){
|
||||
if (compressor.has_directive("use asm")) return false;
|
||||
// AST_Call fallback
|
||||
var pure = compressor.option("pure_funcs");
|
||||
if (!pure) return true;
|
||||
return pure.indexOf(this.expression.print_to_string()) < 0;
|
||||
});
|
||||
|
||||
def(AST_Call, function(compressor){
|
||||
var pure = compressor.option("pure_funcs");
|
||||
if (!pure) return true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user