CodeBlock: Size m_exceptionHandlers to fit from creation.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 Jan 2014 23:09:48 +0000 (23:09 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 Jan 2014 23:09:48 +0000 (23:09 +0000)
<https://webkit.org/b/127234>

Avoid allocation churn for CodeBlock::m_exceptionHandlers.

Reviewed by Anders Carlsson.

* bytecode/CodeBlock.h:

    Removed unused CodeBlock::allocateHandlers() function.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::CodeBlock):

    Use resizeToFit() instead of grow() for m_exceptionHandlers
    since we know it's never going to change size.

(JSC::CodeBlock::shrinkToFit):

    No need to shrink m_exceptionHandlers here since it's already
    the perfect size.

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecode/CodeBlock.cpp
Source/JavaScriptCore/bytecode/CodeBlock.h

index 7540b580cf49810cf64a5b67781dff5117c87836..97765c9e4451b3ed47b1e4a62cd53e660e08020c 100644 (file)
@@ -1,3 +1,27 @@
+2014-01-18  Andreas Kling  <akling@apple.com>
+
+        CodeBlock: Size m_exceptionHandlers to fit from creation.
+        <https://webkit.org/b/127234>
+
+        Avoid allocation churn for CodeBlock::m_exceptionHandlers.
+
+        Reviewed by Anders Carlsson.
+
+        * bytecode/CodeBlock.h:
+
+            Removed unused CodeBlock::allocateHandlers() function.
+
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::CodeBlock):
+
+            Use resizeToFit() instead of grow() for m_exceptionHandlers
+            since we know it's never going to change size.
+
+        (JSC::CodeBlock::shrinkToFit):
+
+            No need to shrink m_exceptionHandlers here since it's already
+            the perfect size.
+
 2014-01-18  Mark Lam  <mark.lam@apple.com>
 
         Add a hasBreakpointFlag arg to the op_debug bytecode.
index a6a89e270d5fd6791040aa323ec2a7254b11aa7e..fb774574614063db59badb13d514624fe0809dd0 100644 (file)
@@ -1601,7 +1601,7 @@ CodeBlock::CodeBlock(ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlin
             }
         }
         if (size_t count = unlinkedCodeBlock->numberOfExceptionHandlers()) {
-            m_rareData->m_exceptionHandlers.grow(count);
+            m_rareData->m_exceptionHandlers.resizeToFit(count);
             size_t nonLocalScopeDepth = scope->depth();
             for (size_t i = 0; i < count; i++) {
                 const UnlinkedHandlerInfo& handler = unlinkedCodeBlock->exceptionHandler(i);
@@ -2601,9 +2601,6 @@ void CodeBlock::shrinkToFit(ShrinkMode shrinkMode)
             m_rareData->m_stringSwitchJumpTables.shrinkToFit();
         }
     } // else don't shrink these, because we would have already pointed pointers into these tables.
-
-    if (m_rareData)
-        m_rareData->m_exceptionHandlers.shrinkToFit();
 }
 
 void CodeBlock::createActivation(CallFrame* callFrame)
index c1263d6333805c07083d3a11b326585a6b18773f..70f624557504eee70beca7c2b3e0f8afe6681de3 100644 (file)
@@ -545,21 +545,6 @@ public:
     // Exception handling support
 
     size_t numberOfExceptionHandlers() const { return m_rareData ? m_rareData->m_exceptionHandlers.size() : 0; }
-    void allocateHandlers(const Vector<UnlinkedHandlerInfo>& unlinkedHandlers)
-    {
-        size_t count = unlinkedHandlers.size();
-        if (!count)
-            return;
-        createRareDataIfNecessary();
-        m_rareData->m_exceptionHandlers.resize(count);
-        for (size_t i = 0; i < count; ++i) {
-            m_rareData->m_exceptionHandlers[i].start = unlinkedHandlers[i].start;
-            m_rareData->m_exceptionHandlers[i].end = unlinkedHandlers[i].end;
-            m_rareData->m_exceptionHandlers[i].target = unlinkedHandlers[i].target;
-            m_rareData->m_exceptionHandlers[i].scopeDepth = unlinkedHandlers[i].scopeDepth;
-        }
-
-    }
     HandlerInfo& exceptionHandler(int index) { RELEASE_ASSERT(m_rareData); return m_rareData->m_exceptionHandlers[index]; }
 
     bool hasExpressionInfo() { return m_unlinkedCode->hasExpressionInfo(); }