Merge branch 'master' into harmony-v3.1.1

This commit is contained in:
alexlamsl
2017-09-17 04:43:43 +08:00
8 changed files with 359 additions and 4 deletions

View File

@@ -579,6 +579,7 @@ merge(Compressor.prototype, {
}
function is_lhs_read_only(lhs) {
if (lhs instanceof AST_This) return true;
if (lhs instanceof AST_SymbolRef) return lhs.definition().orig[0] instanceof AST_SymbolLambda;
if (lhs instanceof AST_PropAccess) {
lhs = lhs.expression;
@@ -782,7 +783,7 @@ merge(Compressor.prototype, {
while (candidates.length > 0) {
var candidate = candidates.pop();
var lhs = get_lhs(candidate);
if (!lhs || is_lhs_read_only(lhs)) continue;
if (!lhs || is_lhs_read_only(lhs) || lhs.has_side_effects(compressor)) continue;
// Locate symbols which may execute code outside of scanning range
var lvalues = get_lvalues(candidate);
if (lhs instanceof AST_SymbolRef) lvalues[lhs.name] = false;
@@ -3710,7 +3711,10 @@ merge(Compressor.prototype, {
&& (left.operator == "++" || left.operator == "--")) {
left = left.expression;
} else left = null;
if (!left || is_lhs_read_only(left) || is_ref_of(left, AST_SymbolConst)) {
if (!left
|| is_lhs_read_only(left)
|| left.has_side_effects(compressor)
|| is_ref_of(left, AST_SymbolConst)) {
expressions[++i] = cdr;
continue;
}