Bug 1457365 - Do not add source note for useless expression. r=jorendorff
authorTooru Fujisawa <arai_a@mac.com>
Tue, 01 May 2018 11:05:39 +0900
changeset 472504 2c8741c94a0dd857b86f48aad3e8f82cb8c5e6d7
parent 472503 e0fcc5bcaf2454e2e2a26a0388863ff746eb02b8
child 472505 32f1ddc878092d0f15517e1ed5e17ce19293a3ff
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1457365
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1457365 - Do not add source note for useless expression. r=jorendorff
js/src/frontend/BytecodeEmitter.cpp
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -8655,19 +8655,16 @@ BytecodeEmitter::emitStatementList(Parse
     return true;
 }
 
 bool
 BytecodeEmitter::emitExpressionStatement(ParseNode* pn)
 {
     MOZ_ASSERT(pn->isKind(ParseNodeKind::ExpressionStatement));
 
-    if (!updateSourceCoordNotes(pn->pn_pos.begin))
-        return false;
-
     /*
      * Top-level or called-from-a-native JS_Execute/EvaluateScript,
      * debugger, and eval frames may need the value of the ultimate
      * expression statement as the script's result, despite the fact
      * that it appears useless to the compiler.
      *
      * API users may also set the JSOPTION_NO_SCRIPT_RVAL option when
      * calling JS_Compile* to suppress JSOP_SETRVAL.
@@ -8697,16 +8694,18 @@ BytecodeEmitter::emitExpressionStatement
             useful = true;
         }
     }
 
     if (useful) {
         JSOp op = wantval ? JSOP_SETRVAL : JSOP_POP;
         ValueUsage valueUsage = wantval ? ValueUsage::WantValue : ValueUsage::IgnoreValue;
         MOZ_ASSERT_IF(expr->isKind(ParseNodeKind::Assign), expr->isOp(JSOP_NOP));
+        if (!updateSourceCoordNotes(pn->pn_pos.begin))
+            return false;
         if (!emitTree(expr, valueUsage))
             return false;
         if (!emit1(op))
             return false;
     } else if (pn->isDirectivePrologueMember()) {
         // Don't complain about directive prologue members; just don't emit
         // their code.
     } else {