Bug 1382973 part 6 - Remove BytecodeAnalysis::hasTryFinally(). r=nbp
authorJan de Mooij <jdemooij@mozilla.com>
Sat, 22 Jul 2017 14:24:29 +0200
changeset 419127 dd2c01041ec8a21b055a672898161938b6f62a2f
parent 419126 99d8af9fffb4ed68872959716c849b478fd8f900
child 419128 bfc33f7e1de45d0c219ea83298cd6813964b8b37
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs1382973
milestone56.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 1382973 part 6 - Remove BytecodeAnalysis::hasTryFinally(). r=nbp
js/src/jit/BytecodeAnalysis.cpp
js/src/jit/IonBuilder.cpp
js/src/jit/IonControlFlow.cpp
js/src/jit/IonControlFlow.h
--- a/js/src/jit/BytecodeAnalysis.cpp
+++ b/js/src/jit/BytecodeAnalysis.cpp
@@ -12,18 +12,17 @@
 #include "jsscriptinlines.h"
 
 using namespace js;
 using namespace js::jit;
 
 BytecodeAnalysis::BytecodeAnalysis(TempAllocator& alloc, JSScript* script)
   : script_(script),
     infos_(alloc),
-    usesEnvironmentChain_(false),
-    hasTryFinally_(false)
+    usesEnvironmentChain_(false)
 {
 }
 
 // Bytecode range containing only catch or finally code.
 struct CatchFinallyRange
 {
     uint32_t start; // Inclusive.
     uint32_t end;   // Exclusive.
@@ -174,20 +173,16 @@ BytecodeAnalysis::init(TempAllocator& al
 
           case JSOP_GETGNAME:
           case JSOP_SETGNAME:
           case JSOP_STRICTSETGNAME:
             if (script_->hasNonSyntacticScope())
                 usesEnvironmentChain_ = true;
             break;
 
-          case JSOP_FINALLY:
-            hasTryFinally_ = true;
-            break;
-
           default:
             break;
         }
 
         bool jump = IsJumpOpcode(op);
         if (jump) {
             // Case instructions do not push the lvalue back when branching.
             unsigned newStackDepth = stackDepth;
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -3017,19 +3017,18 @@ IonBuilder::visitCompare(CFGCompare* com
     current = nullptr;
 
     return Ok();
 }
 
 AbortReasonOr<Ok>
 IonBuilder::visitTry(CFGTry* try_)
 {
-    // Try-finally is not yet supported.
-    if (analysis().hasTryFinally())
-        return abort(AbortReason::Disable, "Has try-finally");
+    // We don't support try-finally. The ControlFlowGenerator should have
+    // aborted compilation in this case.
 
     // Try-catch within inline frames is not yet supported.
     MOZ_ASSERT(!isInlineBuilder());
 
     // Try-catch during the arguments usage analysis is not yet supported. Code
     // accessing the arguments within the 'catch' block is not accounted for.
     if (info().analysisMode() == Analysis_ArgumentsUsage)
         return abort(AbortReason::Disable, "Try-catch during arguments usage analysis");
--- a/js/src/jit/IonControlFlow.cpp
+++ b/js/src/jit/IonControlFlow.cpp
@@ -18,17 +18,18 @@ ControlFlowGenerator::ControlFlowGenerat
     current(nullptr),
     alloc_(temp),
     blocks_(temp),
     cfgStack_(temp),
     loops_(temp),
     switches_(temp),
     labels_(temp),
     analysis_(temp, script),
-    aborted_(false)
+    aborted_(false),
+    checkedTryFinally_(false)
 { }
 
 bool
 ControlFlowGenerator::init()
 {
     return analysis_.init(alloc(), gsn);
 }
 
@@ -534,18 +535,25 @@ ControlFlowGenerator::processLabelEnd(CF
 }
 
 ControlFlowGenerator::ControlStatus
 ControlFlowGenerator::processTry()
 {
     MOZ_ASSERT(JSOp(*pc) == JSOP_TRY);
 
     // Try-finally is not yet supported.
-    if (analysis_.hasTryFinally())
-        return ControlStatus::Abort;
+    if (!checkedTryFinally_) {
+        JSTryNote* tn = script->trynotes()->vector;
+        JSTryNote* tnlimit = tn + script->trynotes()->length;
+        for (; tn < tnlimit; tn++) {
+            if (tn->kind == JSTRY_FINALLY)
+                return ControlStatus::Abort;
+        }
+        checkedTryFinally_ = true;
+    }
 
     jssrcnote* sn = GetSrcNote(gsn, script, pc);
     MOZ_ASSERT(SN_TYPE(sn) == SRC_TRY);
 
     // Get the pc of the last instruction in the try block. It's a JSOP_GOTO to
     // jump over the catch block.
     jsbytecode* endpc = pc + GetSrcNoteOffset(sn, 0);
     MOZ_ASSERT(JSOp(*endpc) == JSOP_GOTO);
--- a/js/src/jit/IonControlFlow.h
+++ b/js/src/jit/IonControlFlow.h
@@ -806,16 +806,17 @@ class ControlFlowGenerator
     };
 
     Vector<CFGState, 8, JitAllocPolicy> cfgStack_;
     Vector<ControlFlowInfo, 4, JitAllocPolicy> loops_;
     Vector<ControlFlowInfo, 0, JitAllocPolicy> switches_;
     Vector<ControlFlowInfo, 2, JitAllocPolicy> labels_;
     BytecodeAnalysis analysis_;
     bool aborted_;
+    bool checkedTryFinally_;
 
   public:
     ControlFlowGenerator(TempAllocator& alloc, JSScript* script);
 
     MOZ_MUST_USE bool init();
 
     MOZ_MUST_USE bool traverseBytecode();
     MOZ_MUST_USE bool addBlock(CFGBlock* block);