Bug 1167823 - Handle more nodes by kind in BytecodeEmitter::checkSideEffects. r=shu
authorJeff Walden <jwalden@mit.edu>
Tue, 19 May 2015 08:29:08 -0700
changeset 247696 a0f2b05a4a5f33e0e1049462afd3771156d26418
parent 247695 d3dadbf59a1a8913ff788783ca1e31ce0561805c
child 247697 6d74cf23229b0da73601ac79d4f6ba3a7622c8d8
push idunknown
push userunknown
push dateunknown
reviewersshu
bugs1167823
milestone41.0a1
Bug 1167823 - Handle more nodes by kind in BytecodeEmitter::checkSideEffects. r=shu
js/src/frontend/BytecodeEmitter.cpp
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -1926,16 +1926,22 @@ BytecodeEmitter::checkSideEffects(ParseN
         *answer = false;
         return true;
 
       case PNK_DEBUGGER:
         MOZ_ASSERT(pn->isArity(PN_NULLARY));
         *answer = true;
         return true;
 
+      // Watch out for getters!
+      case PNK_SUPERPROP:
+        MOZ_ASSERT(pn->isArity(PN_NULLARY));
+        *answer = true;
+        return true;
+
       // Unary cases with side effects only if the child has them.
       case PNK_TYPEOFEXPR:
       case PNK_VOID:
       case PNK_NOT:
       case PNK_COMPUTED_NAME:
         MOZ_ASSERT(pn->isArity(PN_UNARY));
         return checkSideEffects(pn->pn_kid, answer);
 
@@ -2002,54 +2008,78 @@ BytecodeEmitter::checkSideEffects(ParseN
 
       case PNK_SEMI:
         MOZ_ASSERT(pn->isArity(PN_UNARY));
         if (ParseNode* expr = pn->pn_kid)
             return checkSideEffects(expr, answer);
         *answer = false;
         return true;
 
-      case PNK_SUPERPROP:
-      case PNK_BREAK:
-      case PNK_CONTINUE:
-      case PNK_EXPORT_BATCH_SPEC:
-      case PNK_FRESHENBLOCK:
-      case PNK_EXPORT:
-      case PNK_EXPORT_DEFAULT:
+      // Binary cases with obvious side effects.
       case PNK_ASSIGN:
       case PNK_ADDASSIGN:
       case PNK_SUBASSIGN:
       case PNK_BITORASSIGN:
       case PNK_BITXORASSIGN:
       case PNK_BITANDASSIGN:
       case PNK_LSHASSIGN:
       case PNK_RSHASSIGN:
       case PNK_URSHASSIGN:
       case PNK_MULASSIGN:
       case PNK_DIVASSIGN:
       case PNK_MODASSIGN:
+        MOZ_ASSERT(pn->isArity(PN_BINARY));
+        *answer = true;
+        return true;
+
+      // More getters.
       case PNK_ELEM:
+        MOZ_ASSERT(pn->isArity(PN_BINARY));
+        *answer = true;
+        return true;
+
+      // Again, getters.
       case PNK_SUPERELEM:
+        MOZ_ASSERT(pn->isArity(PN_UNARY));
+        *answer = true;
+        return true;
+
+      // These affect visible names in this code, or in other code.
+      case PNK_IMPORT:
+      case PNK_EXPORT_FROM:
+        MOZ_ASSERT(pn->isArity(PN_BINARY));
+        *answer = true;
+        return true;
+
+      // Likewise.
+      case PNK_EXPORT:
+        MOZ_ASSERT(pn->isArity(PN_UNARY));
+        *answer = true;
+        return true;
+
+      case PNK_BREAK:
+      case PNK_CONTINUE:
+      case PNK_EXPORT_BATCH_SPEC:
+      case PNK_FRESHENBLOCK:
+      case PNK_EXPORT_DEFAULT:
       case PNK_COLON:
       case PNK_CASE:
       case PNK_SHORTHAND:
       case PNK_DOWHILE:
       case PNK_WHILE:
       case PNK_SWITCH:
       case PNK_LETBLOCK:
       case PNK_FOR:
       case PNK_CLASSMETHOD:
       case PNK_WITH:
       case PNK_CLASSNAMES:
       case PNK_DEFAULT:
       case PNK_YIELD_STAR:
       case PNK_YIELD:
       case PNK_RETURN:
-      case PNK_IMPORT:
-      case PNK_EXPORT_FROM:
       case PNK_CONDITIONAL:
       case PNK_FORIN:
       case PNK_FOROF:
       case PNK_FORHEAD:
       case PNK_CLASS:
       case PNK_IF:
       case PNK_TRY:
       case PNK_OR: