BytecodeGenerator::m_finallyDepth should be unsigned.
authormark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Dec 2016 23:23:51 +0000 (23:23 +0000)
committermark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Dec 2016 23:23:51 +0000 (23:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=166438

Reviewed by Saam Barati.

Also removed FinallyContext::m_finallyDepth because it is not used.

* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::pushFinallyControlFlowScope):
(JSC::BytecodeGenerator::labelScopeDepth):
* bytecompiler/BytecodeGenerator.h:
(JSC::FinallyContext::FinallyContext):
(JSC::FinallyContext::finallyLabel):
(JSC::FinallyContext::depth): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210119 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

index 97c0903..edbb66c 100644 (file)
@@ -1,5 +1,22 @@
 2016-12-22  Mark Lam  <mark.lam@apple.com>
 
+        BytecodeGenerator::m_finallyDepth should be unsigned.
+        https://bugs.webkit.org/show_bug.cgi?id=166438
+
+        Reviewed by Saam Barati.
+
+        Also removed FinallyContext::m_finallyDepth because it is not used.
+
+        * bytecompiler/BytecodeGenerator.cpp:
+        (JSC::BytecodeGenerator::pushFinallyControlFlowScope):
+        (JSC::BytecodeGenerator::labelScopeDepth):
+        * bytecompiler/BytecodeGenerator.h:
+        (JSC::FinallyContext::FinallyContext):
+        (JSC::FinallyContext::finallyLabel):
+        (JSC::FinallyContext::depth): Deleted.
+
+2016-12-22  Mark Lam  <mark.lam@apple.com>
+
         De-duplicate finally blocks.
         https://bugs.webkit.org/show_bug.cgi?id=160168
 
index df08d2c..423e574 100644 (file)
@@ -3687,7 +3687,7 @@ FinallyContext* BytecodeGenerator::pushFinallyControlFlowScope(Label* finallyLab
     while (m_labelScopes.size() && !m_labelScopes.last().refCount())
         m_labelScopes.removeLast();
 
-    ControlFlowScope scope(ControlFlowScope::Finally, currentLexicalScopeIndex(), FinallyContext(m_currentFinallyContext, finallyLabel, m_finallyDepth));
+    ControlFlowScope scope(ControlFlowScope::Finally, currentLexicalScopeIndex(), FinallyContext(m_currentFinallyContext, finallyLabel));
     m_controlFlowScopeStack.append(WTFMove(scope));
 
     m_finallyDepth++;
@@ -3886,8 +3886,8 @@ int BytecodeGenerator::localScopeDepth() const
 
 int BytecodeGenerator::labelScopeDepth() const
 {
-    int depth = localScopeDepth() + m_finallyDepth;
-    ASSERT(depth == static_cast<int>(m_controlFlowScopeStack.size()));
+    unsigned depth = localScopeDepth() + m_finallyDepth;
+    ASSERT(depth == m_controlFlowScopeStack.size());
     return depth;
 }
 
index 6aef19b..0aaec9d 100644 (file)
@@ -121,18 +121,15 @@ namespace JSC {
 
     struct FinallyContext {
         FinallyContext() { }
-        FinallyContext(FinallyContext* outerContext, Label* finallyLabel, int finallyDepth)
+        FinallyContext(FinallyContext* outerContext, Label* finallyLabel)
             : m_outerContext(outerContext)
             , m_finallyLabel(finallyLabel)
-            , m_finallyDepth(finallyDepth)
         {
-            ASSERT(m_finallyDepth >= 0);
             ASSERT(m_jumps.isEmpty());
         }
 
         FinallyContext* outerContext() const { return m_outerContext; }
         Label* finallyLabel() const { return m_finallyLabel; }
-        int depth() const { return m_finallyDepth; }
 
         uint32_t numberOfBreaksOrContinues() const { return m_numberOfBreaksOrContinues.unsafeGet(); }
         void incNumberOfBreaksOrContinues() { m_numberOfBreaksOrContinues++; }
@@ -151,7 +148,6 @@ namespace JSC {
     private:
         FinallyContext* m_outerContext { nullptr };
         Label* m_finallyLabel { nullptr };
-        int m_finallyDepth { 0 };
         Checked<uint32_t, WTF::CrashOnOverflow> m_numberOfBreaksOrContinues;
         bool m_handlesReturns { false };
         Vector<FinallyJump> m_jumps;
@@ -1091,7 +1087,7 @@ namespace JSC {
         SegmentedVector<RegisterID, 32> m_parameters;
         SegmentedVector<Label, 32> m_labels;
         LabelScopeStore m_labelScopes;
-        int m_finallyDepth { 0 };
+        unsigned m_finallyDepth { 0 };
         int m_localScopeDepth { 0 };
         const CodeType m_codeType;