<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[170697] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/170697">170697</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2014-07-01 21:49:39 -0700 (Tue, 01 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Reduce dynamic memory allocation in css jit.
https://bugs.webkit.org/show_bug.cgi?id=134416

Reviewed by Benjamin Poulain.


Source/WebCore: 
* cssjit/FunctionCall.h:
(WebCore::FunctionCall::saveAllocatedRegisters):
* cssjit/RegisterAllocator.h:
* cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::addPseudoClassType):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateSelectorChecker):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsNthChild):
* cssjit/StackAllocator.h:
(WebCore::StackAllocator::push):
(WebCore::StackAllocator::pop):
Use inlineCapacity template parameter to reduce malloc calls.
I use 32 as the inline capacity for non-register related vectors because that
is probably big enough for the selector compiler, and if it is not then a malloc
call will not be significant because the selector is very complex.

Source/WTF: 
* wtf/Deque.h:
Added inlineCapacity optional template parameter.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfDequeh">trunk/Source/WTF/wtf/Deque.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssjitFunctionCallh">trunk/Source/WebCore/cssjit/FunctionCall.h</a></li>
<li><a href="#trunkSourceWebCorecssjitRegisterAllocatorh">trunk/Source/WebCore/cssjit/RegisterAllocator.h</a></li>
<li><a href="#trunkSourceWebCorecssjitSelectorCompilercpp">trunk/Source/WebCore/cssjit/SelectorCompiler.cpp</a></li>
<li><a href="#trunkSourceWebCorecssjitStackAllocatorh">trunk/Source/WebCore/cssjit/StackAllocator.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (170696 => 170697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2014-07-02 04:49:27 UTC (rev 170696)
+++ trunk/Source/WTF/ChangeLog        2014-07-02 04:49:39 UTC (rev 170697)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2014-07-01  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        Reduce dynamic memory allocation in css jit.
+        https://bugs.webkit.org/show_bug.cgi?id=134416
+
+        Reviewed by Benjamin Poulain.
+
+        * wtf/Deque.h:
+        Added inlineCapacity optional template parameter.
+
</ins><span class="cx"> 2014-06-30  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r170605.
</span></span></pre></div>
<a id="trunkSourceWTFwtfDequeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Deque.h (170696 => 170697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Deque.h        2014-07-02 04:49:27 UTC (rev 170696)
+++ trunk/Source/WTF/wtf/Deque.h        2014-07-02 04:49:39 UTC (rev 170697)
</span><span class="lines">@@ -38,25 +38,25 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WTF {
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt; class DequeIteratorBase;
-    template&lt;typename T&gt; class DequeIterator;
-    template&lt;typename T&gt; class DequeConstIterator;
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt; class DequeIteratorBase;
+    template&lt;typename T, size_t inlineCapacity&gt; class DequeIterator;
+    template&lt;typename T, size_t inlineCapacity&gt; class DequeConstIterator;
</ins><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
</del><ins>+    template&lt;typename T, size_t inlineCapacity = 0&gt;
</ins><span class="cx">     class Deque {
</span><span class="cx">         WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx">     public:
</span><del>-        typedef DequeIterator&lt;T&gt; iterator;
-        typedef DequeConstIterator&lt;T&gt; const_iterator;
</del><ins>+        typedef DequeIterator&lt;T, inlineCapacity&gt; iterator;
+        typedef DequeConstIterator&lt;T, inlineCapacity&gt; const_iterator;
</ins><span class="cx">         typedef std::reverse_iterator&lt;iterator&gt; reverse_iterator;
</span><span class="cx">         typedef std::reverse_iterator&lt;const_iterator&gt; const_reverse_iterator;
</span><span class="cx"> 
</span><span class="cx">         Deque();
</span><del>-        Deque(const Deque&lt;T&gt;&amp;);
-        Deque&amp; operator=(const Deque&lt;T&gt;&amp;);
</del><ins>+        Deque(const Deque&lt;T, inlineCapacity&gt;&amp;);
+        Deque&amp; operator=(const Deque&lt;T, inlineCapacity&gt;&amp;);
</ins><span class="cx">         ~Deque();
</span><span class="cx"> 
</span><del>-        void swap(Deque&lt;T&gt;&amp;);
</del><ins>+        void swap(Deque&lt;T, inlineCapacity&gt;&amp;);
</ins><span class="cx"> 
</span><span class="cx">         size_t size() const { return m_start &lt;= m_end ? m_end - m_start : m_end + m_buffer.capacity() - m_start; }
</span><span class="cx">         bool isEmpty() const { return m_start == m_end; }
</span><span class="lines">@@ -91,11 +91,11 @@
</span><span class="cx">         iterator findIf(Predicate&amp;&amp;);
</span><span class="cx"> 
</span><span class="cx">     private:
</span><del>-        friend class DequeIteratorBase&lt;T&gt;;
</del><ins>+        friend class DequeIteratorBase&lt;T, inlineCapacity&gt;;
</ins><span class="cx"> 
</span><del>-        typedef VectorBuffer&lt;T, 0&gt; Buffer;
</del><ins>+        typedef VectorBuffer&lt;T, inlineCapacity&gt; Buffer;
</ins><span class="cx">         typedef VectorTypeOperations&lt;T&gt; TypeOperations;
</span><del>-        typedef DequeIteratorBase&lt;T&gt; IteratorBase;
</del><ins>+        typedef DequeIteratorBase&lt;T, inlineCapacity&gt; IteratorBase;
</ins><span class="cx"> 
</span><span class="cx">         void remove(size_t position);
</span><span class="cx">         void invalidateIterators();
</span><span class="lines">@@ -113,11 +113,11 @@
</span><span class="cx"> #endif
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
</ins><span class="cx">     class DequeIteratorBase {
</span><span class="cx">     protected:
</span><span class="cx">         DequeIteratorBase();
</span><del>-        DequeIteratorBase(const Deque&lt;T&gt;*, size_t);
</del><ins>+        DequeIteratorBase(const Deque&lt;T, inlineCapacity&gt;*, size_t);
</ins><span class="cx">         DequeIteratorBase(const DequeIteratorBase&amp;);
</span><span class="cx">         DequeIteratorBase&amp; operator=(const DequeIteratorBase&amp;);
</span><span class="cx">         ~DequeIteratorBase();
</span><span class="lines">@@ -138,10 +138,10 @@
</span><span class="cx">         void checkValidity() const;
</span><span class="cx">         void checkValidity(const DequeIteratorBase&amp;) const;
</span><span class="cx"> 
</span><del>-        Deque&lt;T&gt;* m_deque;
</del><ins>+        Deque&lt;T, inlineCapacity&gt;* m_deque;
</ins><span class="cx">         size_t m_index;
</span><span class="cx"> 
</span><del>-        friend class Deque&lt;T&gt;;
</del><ins>+        friend class Deque&lt;T, inlineCapacity&gt;;
</ins><span class="cx"> 
</span><span class="cx"> #ifndef NDEBUG
</span><span class="cx">         mutable DequeIteratorBase* m_next;
</span><span class="lines">@@ -149,11 +149,11 @@
</span><span class="cx"> #endif
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    class DequeIterator : public DequeIteratorBase&lt;T&gt; {
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    class DequeIterator : public DequeIteratorBase&lt;T, inlineCapacity&gt; {
</ins><span class="cx">     private:
</span><del>-        typedef DequeIteratorBase&lt;T&gt; Base;
-        typedef DequeIterator&lt;T&gt; Iterator;
</del><ins>+        typedef DequeIteratorBase&lt;T, inlineCapacity&gt; Base;
+        typedef DequeIterator&lt;T, inlineCapacity&gt; Iterator;
</ins><span class="cx"> 
</span><span class="cx">     public:
</span><span class="cx">         typedef ptrdiff_t difference_type;
</span><span class="lines">@@ -162,7 +162,8 @@
</span><span class="cx">         typedef T&amp; reference;
</span><span class="cx">         typedef std::bidirectional_iterator_tag iterator_category;
</span><span class="cx"> 
</span><del>-        DequeIterator(Deque&lt;T&gt;* deque, size_t index) : Base(deque, index) { }
</del><ins>+        DequeIterator(Deque&lt;T, inlineCapacity&gt;* deque, size_t index)
+            : Base(deque, index) { }
</ins><span class="cx"> 
</span><span class="cx">         DequeIterator(const Iterator&amp; other) : Base(other) { }
</span><span class="cx">         DequeIterator&amp; operator=(const Iterator&amp; other) { Base::assign(other); return *this; }
</span><span class="lines">@@ -179,12 +180,12 @@
</span><span class="cx">         // postfix -- intentionally omitted
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    class DequeConstIterator : public DequeIteratorBase&lt;T&gt; {
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    class DequeConstIterator : public DequeIteratorBase&lt;T, inlineCapacity&gt; {
</ins><span class="cx">     private:
</span><del>-        typedef DequeIteratorBase&lt;T&gt; Base;
-        typedef DequeConstIterator&lt;T&gt; Iterator;
-        typedef DequeIterator&lt;T&gt; NonConstIterator;
</del><ins>+        typedef DequeIteratorBase&lt;T, inlineCapacity&gt; Base;
+        typedef DequeConstIterator&lt;T, inlineCapacity&gt; Iterator;
+        typedef DequeIterator&lt;T, inlineCapacity&gt; NonConstIterator;
</ins><span class="cx"> 
</span><span class="cx">     public:
</span><span class="cx">         typedef ptrdiff_t difference_type;
</span><span class="lines">@@ -193,7 +194,8 @@
</span><span class="cx">         typedef const T&amp; reference;
</span><span class="cx">         typedef std::bidirectional_iterator_tag iterator_category;
</span><span class="cx"> 
</span><del>-        DequeConstIterator(const Deque&lt;T&gt;* deque, size_t index) : Base(deque, index) { }
</del><ins>+        DequeConstIterator(const Deque&lt;T, inlineCapacity&gt;* deque, size_t index)
+            : Base(deque, index) { }
</ins><span class="cx"> 
</span><span class="cx">         DequeConstIterator(const Iterator&amp; other) : Base(other) { }
</span><span class="cx">         DequeConstIterator(const NonConstIterator&amp; other) : Base(other) { }
</span><span class="lines">@@ -213,12 +215,12 @@
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx"> #ifdef NDEBUG
</span><del>-    template&lt;typename T&gt; inline void Deque&lt;T&gt;::checkValidity() const { }
-    template&lt;typename T&gt; inline void Deque&lt;T&gt;::checkIndexValidity(size_t) const { }
-    template&lt;typename T&gt; inline void Deque&lt;T&gt;::invalidateIterators() { }
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt; inline void Deque&lt;T, inlineCapacity&gt;::checkValidity() const { }
+    template&lt;typename T, size_t inlineCapacity&gt; inline void Deque&lt;T, inlineCapacity&gt;::checkIndexValidity(size_t) const { }
+    template&lt;typename T, size_t inlineCapacity&gt; inline void Deque&lt;T, inlineCapacity&gt;::invalidateIterators() { }
</ins><span class="cx"> #else
</span><del>-    template&lt;typename T&gt;
-    void Deque&lt;T&gt;::checkValidity() const
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    void Deque&lt;T, inlineCapacity&gt;::checkValidity() const
</ins><span class="cx">     {
</span><span class="cx">         // In this implementation a capacity of 1 would confuse append() and
</span><span class="cx">         // other places that assume the index after capacity - 1 is 0.
</span><span class="lines">@@ -233,8 +235,8 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    void Deque&lt;T&gt;::checkIndexValidity(size_t index) const
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    void Deque&lt;T, inlineCapacity&gt;::checkIndexValidity(size_t index) const
</ins><span class="cx">     {
</span><span class="cx">         ASSERT_UNUSED(index, index &lt;= m_buffer.capacity());
</span><span class="cx">         if (m_start &lt;= m_end) {
</span><span class="lines">@@ -245,8 +247,8 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    void Deque&lt;T&gt;::invalidateIterators()
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    void Deque&lt;T, inlineCapacity&gt;::invalidateIterators()
</ins><span class="cx">     {
</span><span class="cx">         IteratorBase* next;
</span><span class="cx">         for (IteratorBase* p = m_iterators; p; p = next) {
</span><span class="lines">@@ -259,8 +261,8 @@
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline Deque&lt;T&gt;::Deque()
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline Deque&lt;T, inlineCapacity&gt;::Deque()
</ins><span class="cx">         : m_start(0)
</span><span class="cx">         , m_end(0)
</span><span class="cx"> #ifndef NDEBUG
</span><span class="lines">@@ -270,8 +272,8 @@
</span><span class="cx">         checkValidity();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline Deque&lt;T&gt;::Deque(const Deque&lt;T&gt;&amp; other)
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline Deque&lt;T, inlineCapacity&gt;::Deque(const Deque&lt;T, inlineCapacity&gt;&amp; other)
</ins><span class="cx">         : m_start(other.m_start)
</span><span class="cx">         , m_end(other.m_end)
</span><span class="cx">         , m_buffer(other.m_buffer.capacity())
</span><span class="lines">@@ -288,18 +290,18 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline Deque&lt;T&gt;&amp; Deque&lt;T&gt;::operator=(const Deque&lt;T&gt;&amp; other)
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline Deque&lt;T, inlineCapacity&gt;&amp; Deque&lt;T, inlineCapacity&gt;::operator=(const Deque&lt;T, inlineCapacity&gt;&amp; other)
</ins><span class="cx">     {
</span><span class="cx">         // FIXME: This is inefficient if we're using an inline buffer and T is
</span><span class="cx">         // expensive to copy since it will copy the buffer twice instead of once.
</span><del>-        Deque&lt;T&gt; copy(other);
</del><ins>+        Deque&lt;T, inlineCapacity&gt; copy(other);
</ins><span class="cx">         swap(copy);
</span><span class="cx">         return *this;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline void Deque&lt;T&gt;::destroyAll()
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline void Deque&lt;T, inlineCapacity&gt;::destroyAll()
</ins><span class="cx">     {
</span><span class="cx">         if (m_start &lt;= m_end)
</span><span class="cx">             TypeOperations::destruct(m_buffer.buffer() + m_start, m_buffer.buffer() + m_end);
</span><span class="lines">@@ -309,16 +311,16 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline Deque&lt;T&gt;::~Deque()
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline Deque&lt;T, inlineCapacity&gt;::~Deque()
</ins><span class="cx">     {
</span><span class="cx">         checkValidity();
</span><span class="cx">         invalidateIterators();
</span><span class="cx">         destroyAll();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline void Deque&lt;T&gt;::swap(Deque&lt;T&gt;&amp; other)
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline void Deque&lt;T, inlineCapacity&gt;::swap(Deque&lt;T, inlineCapacity&gt;&amp; other)
</ins><span class="cx">     {
</span><span class="cx">         checkValidity();
</span><span class="cx">         other.checkValidity();
</span><span class="lines">@@ -330,8 +332,8 @@
</span><span class="cx">         other.checkValidity();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline void Deque&lt;T&gt;::clear()
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline void Deque&lt;T, inlineCapacity&gt;::clear()
</ins><span class="cx">     {
</span><span class="cx">         checkValidity();
</span><span class="cx">         invalidateIterators();
</span><span class="lines">@@ -342,9 +344,9 @@
</span><span class="cx">         checkValidity();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
</ins><span class="cx">     template&lt;typename Predicate&gt;
</span><del>-    inline auto Deque&lt;T&gt;::findIf(Predicate&amp;&amp; predicate) -&gt; iterator
</del><ins>+    inline auto Deque&lt;T, inlineCapacity&gt;::findIf(Predicate&amp;&amp; predicate) -&gt; iterator
</ins><span class="cx">     {
</span><span class="cx">         iterator end_iterator = end();
</span><span class="cx">         for (iterator it = begin(); it != end_iterator; ++it) {
</span><span class="lines">@@ -354,8 +356,8 @@
</span><span class="cx">         return end_iterator;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline void Deque&lt;T&gt;::expandCapacityIfNeeded()
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline void Deque&lt;T, inlineCapacity&gt;::expandCapacityIfNeeded()
</ins><span class="cx">     {
</span><span class="cx">         if (m_start) {
</span><span class="cx">             if (m_end + 1 != m_start)
</span><span class="lines">@@ -369,8 +371,8 @@
</span><span class="cx">         expandCapacity();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    void Deque&lt;T&gt;::expandCapacity()
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    void Deque&lt;T, inlineCapacity&gt;::expandCapacity()
</ins><span class="cx">     {
</span><span class="cx">         checkValidity();
</span><span class="cx">         size_t oldCapacity = m_buffer.capacity();
</span><span class="lines">@@ -388,24 +390,24 @@
</span><span class="cx">         checkValidity();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline auto Deque&lt;T&gt;::takeFirst() -&gt; T
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline auto Deque&lt;T, inlineCapacity&gt;::takeFirst() -&gt; T
</ins><span class="cx">     {
</span><span class="cx">         T oldFirst = std::move(first());
</span><span class="cx">         removeFirst();
</span><span class="cx">         return oldFirst;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline auto Deque&lt;T&gt;::takeLast() -&gt; T
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline auto Deque&lt;T, inlineCapacity&gt;::takeLast() -&gt; T
</ins><span class="cx">     {
</span><span class="cx">         T oldLast = std::move(last());
</span><span class="cx">         removeLast();
</span><span class="cx">         return oldLast;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt; template&lt;typename U&gt;
-    inline void Deque&lt;T&gt;::append(U&amp;&amp; value)
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt; template&lt;typename U&gt;
+    inline void Deque&lt;T, inlineCapacity&gt;::append(U&amp;&amp; value)
</ins><span class="cx">     {
</span><span class="cx">         checkValidity();
</span><span class="cx">         expandCapacityIfNeeded();
</span><span class="lines">@@ -417,8 +419,8 @@
</span><span class="cx">         checkValidity();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt; template&lt;typename U&gt;
-    inline void Deque&lt;T&gt;::prepend(U&amp;&amp; value)
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt; template&lt;typename U&gt;
+    inline void Deque&lt;T, inlineCapacity&gt;::prepend(U&amp;&amp; value)
</ins><span class="cx">     {
</span><span class="cx">         checkValidity();
</span><span class="cx">         expandCapacityIfNeeded();
</span><span class="lines">@@ -430,8 +432,8 @@
</span><span class="cx">         checkValidity();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline void Deque&lt;T&gt;::removeFirst()
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline void Deque&lt;T, inlineCapacity&gt;::removeFirst()
</ins><span class="cx">     {
</span><span class="cx">         checkValidity();
</span><span class="cx">         invalidateIterators();
</span><span class="lines">@@ -444,8 +446,8 @@
</span><span class="cx">         checkValidity();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline void Deque&lt;T&gt;::removeLast()
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline void Deque&lt;T, inlineCapacity&gt;::removeLast()
</ins><span class="cx">     {
</span><span class="cx">         checkValidity();
</span><span class="cx">         invalidateIterators();
</span><span class="lines">@@ -458,22 +460,22 @@
</span><span class="cx">         checkValidity();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline void Deque&lt;T&gt;::remove(iterator&amp; it)
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline void Deque&lt;T, inlineCapacity&gt;::remove(iterator&amp; it)
</ins><span class="cx">     {
</span><span class="cx">         it.checkValidity();
</span><span class="cx">         remove(it.m_index);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline void Deque&lt;T&gt;::remove(const_iterator&amp; it)
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline void Deque&lt;T, inlineCapacity&gt;::remove(const_iterator&amp; it)
</ins><span class="cx">     {
</span><span class="cx">         it.checkValidity();
</span><span class="cx">         remove(it.m_index);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline void Deque&lt;T&gt;::remove(size_t position)
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline void Deque&lt;T, inlineCapacity&gt;::remove(size_t position)
</ins><span class="cx">     {
</span><span class="cx">         if (position == m_end)
</span><span class="cx">             return;
</span><span class="lines">@@ -496,28 +498,28 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> #ifdef NDEBUG
</span><del>-    template&lt;typename T&gt; inline void DequeIteratorBase&lt;T&gt;::checkValidity() const { }
-    template&lt;typename T&gt; inline void DequeIteratorBase&lt;T&gt;::checkValidity(const DequeIteratorBase&lt;T&gt;&amp;) const { }
-    template&lt;typename T&gt; inline void DequeIteratorBase&lt;T&gt;::addToIteratorsList() { }
-    template&lt;typename T&gt; inline void DequeIteratorBase&lt;T&gt;::removeFromIteratorsList() { }
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt; inline void DequeIteratorBase&lt;T, inlineCapacity&gt;::checkValidity() const { }
+    template&lt;typename T, size_t inlineCapacity&gt; inline void DequeIteratorBase&lt;T, inlineCapacity&gt;::checkValidity(const DequeIteratorBase&lt;T, inlineCapacity&gt;&amp;) const { }
+    template&lt;typename T, size_t inlineCapacity&gt; inline void DequeIteratorBase&lt;T, inlineCapacity&gt;::addToIteratorsList() { }
+    template&lt;typename T, size_t inlineCapacity&gt; inline void DequeIteratorBase&lt;T, inlineCapacity&gt;::removeFromIteratorsList() { }
</ins><span class="cx"> #else
</span><del>-    template&lt;typename T&gt;
-    void DequeIteratorBase&lt;T&gt;::checkValidity() const
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    void DequeIteratorBase&lt;T, inlineCapacity&gt;::checkValidity() const
</ins><span class="cx">     {
</span><span class="cx">         ASSERT(m_deque);
</span><span class="cx">         m_deque-&gt;checkIndexValidity(m_index);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    void DequeIteratorBase&lt;T&gt;::checkValidity(const DequeIteratorBase&amp; other) const
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    void DequeIteratorBase&lt;T, inlineCapacity&gt;::checkValidity(const DequeIteratorBase&amp; other) const
</ins><span class="cx">     {
</span><span class="cx">         checkValidity();
</span><span class="cx">         other.checkValidity();
</span><span class="cx">         ASSERT(m_deque == other.m_deque);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    void DequeIteratorBase&lt;T&gt;::addToIteratorsList()
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    void DequeIteratorBase&lt;T, inlineCapacity&gt;::addToIteratorsList()
</ins><span class="cx">     {
</span><span class="cx">         if (!m_deque)
</span><span class="cx">             m_next = 0;
</span><span class="lines">@@ -530,8 +532,8 @@
</span><span class="cx">         m_previous = 0;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    void DequeIteratorBase&lt;T&gt;::removeFromIteratorsList()
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    void DequeIteratorBase&lt;T, inlineCapacity&gt;::removeFromIteratorsList()
</ins><span class="cx">     {
</span><span class="cx">         if (!m_deque) {
</span><span class="cx">             ASSERT(!m_next);
</span><span class="lines">@@ -555,23 +557,23 @@
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline DequeIteratorBase&lt;T&gt;::DequeIteratorBase()
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline DequeIteratorBase&lt;T, inlineCapacity&gt;::DequeIteratorBase()
</ins><span class="cx">         : m_deque(0)
</span><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline DequeIteratorBase&lt;T&gt;::DequeIteratorBase(const Deque&lt;T&gt;* deque, size_t index)
-        : m_deque(const_cast&lt;Deque&lt;T&gt;*&gt;(deque))
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline DequeIteratorBase&lt;T, inlineCapacity&gt;::DequeIteratorBase(const Deque&lt;T, inlineCapacity&gt;* deque, size_t index)
+        : m_deque(const_cast&lt;Deque&lt;T, inlineCapacity&gt;*&gt;(deque))
</ins><span class="cx">         , m_index(index)
</span><span class="cx">     {
</span><span class="cx">         addToIteratorsList();
</span><span class="cx">         checkValidity();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline DequeIteratorBase&lt;T&gt;::DequeIteratorBase(const DequeIteratorBase&amp; other)
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline DequeIteratorBase&lt;T, inlineCapacity&gt;::DequeIteratorBase(const DequeIteratorBase&amp; other)
</ins><span class="cx">         : m_deque(other.m_deque)
</span><span class="cx">         , m_index(other.m_index)
</span><span class="cx">     {
</span><span class="lines">@@ -579,8 +581,8 @@
</span><span class="cx">         checkValidity();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline DequeIteratorBase&lt;T&gt;&amp; DequeIteratorBase&lt;T&gt;::operator=(const DequeIteratorBase&amp; other)
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline DequeIteratorBase&lt;T, inlineCapacity&gt;&amp; DequeIteratorBase&lt;T, inlineCapacity&gt;::operator=(const DequeIteratorBase&amp; other)
</ins><span class="cx">     {
</span><span class="cx">         other.checkValidity();
</span><span class="cx">         removeFromIteratorsList();
</span><span class="lines">@@ -592,8 +594,8 @@
</span><span class="cx">         return *this;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline DequeIteratorBase&lt;T&gt;::~DequeIteratorBase()
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline DequeIteratorBase&lt;T, inlineCapacity&gt;::~DequeIteratorBase()
</ins><span class="cx">     {
</span><span class="cx"> #ifndef NDEBUG
</span><span class="cx">         removeFromIteratorsList();
</span><span class="lines">@@ -601,15 +603,15 @@
</span><span class="cx"> #endif
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline bool DequeIteratorBase&lt;T&gt;::isEqual(const DequeIteratorBase&amp; other) const
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline bool DequeIteratorBase&lt;T, inlineCapacity&gt;::isEqual(const DequeIteratorBase&amp; other) const
</ins><span class="cx">     {
</span><span class="cx">         checkValidity(other);
</span><span class="cx">         return m_index == other.m_index;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline void DequeIteratorBase&lt;T&gt;::increment()
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline void DequeIteratorBase&lt;T, inlineCapacity&gt;::increment()
</ins><span class="cx">     {
</span><span class="cx">         checkValidity();
</span><span class="cx">         ASSERT(m_index != m_deque-&gt;m_end);
</span><span class="lines">@@ -621,8 +623,8 @@
</span><span class="cx">         checkValidity();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline void DequeIteratorBase&lt;T&gt;::decrement()
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline void DequeIteratorBase&lt;T, inlineCapacity&gt;::decrement()
</ins><span class="cx">     {
</span><span class="cx">         checkValidity();
</span><span class="cx">         ASSERT(m_index != m_deque-&gt;m_start);
</span><span class="lines">@@ -634,16 +636,16 @@
</span><span class="cx">         checkValidity();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline T* DequeIteratorBase&lt;T&gt;::after() const
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline T* DequeIteratorBase&lt;T, inlineCapacity&gt;::after() const
</ins><span class="cx">     {
</span><span class="cx">         checkValidity();
</span><span class="cx">         ASSERT(m_index != m_deque-&gt;m_end);
</span><span class="cx">         return &amp;m_deque-&gt;m_buffer.buffer()[m_index];
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    template&lt;typename T&gt;
-    inline T* DequeIteratorBase&lt;T&gt;::before() const
</del><ins>+    template&lt;typename T, size_t inlineCapacity&gt;
+    inline T* DequeIteratorBase&lt;T, inlineCapacity&gt;::before() const
</ins><span class="cx">     {
</span><span class="cx">         checkValidity();
</span><span class="cx">         ASSERT(m_index != m_deque-&gt;m_start);
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (170696 => 170697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-07-02 04:49:27 UTC (rev 170696)
+++ trunk/Source/WebCore/ChangeLog        2014-07-02 04:49:39 UTC (rev 170697)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2014-07-01  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        Reduce dynamic memory allocation in css jit.
+        https://bugs.webkit.org/show_bug.cgi?id=134416
+
+        Reviewed by Benjamin Poulain.
+
+        * cssjit/FunctionCall.h:
+        (WebCore::FunctionCall::saveAllocatedRegisters):
+        * cssjit/RegisterAllocator.h:
+        * cssjit/SelectorCompiler.cpp:
+        (WebCore::SelectorCompiler::addPseudoClassType):
+        (WebCore::SelectorCompiler::SelectorCodeGenerator::generateSelectorChecker):
+        (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsNthChild):
+        * cssjit/StackAllocator.h:
+        (WebCore::StackAllocator::push):
+        (WebCore::StackAllocator::pop):
+        Use inlineCapacity template parameter to reduce malloc calls.
+        I use 32 as the inline capacity for non-register related vectors because that
+        is probably big enough for the selector compiler, and if it is not then a malloc
+        call will not be significant because the selector is very complex.
+
</ins><span class="cx"> 2014-07-01  Eric Carlson  &lt;eric.carlson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebVTT percentage value can be a float
</span></span></pre></div>
<a id="trunkSourceWebCorecssjitFunctionCallh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/cssjit/FunctionCall.h (170696 => 170697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/cssjit/FunctionCall.h        2014-07-02 04:49:27 UTC (rev 170696)
+++ trunk/Source/WebCore/cssjit/FunctionCall.h        2014-07-02 04:49:39 UTC (rev 170697)
</span><span class="lines">@@ -37,7 +37,7 @@
</span><span class="cx"> 
</span><span class="cx"> class FunctionCall {
</span><span class="cx"> public:
</span><del>-    FunctionCall(JSC::MacroAssembler&amp; assembler, RegisterAllocator&amp; registerAllocator, StackAllocator&amp; stackAllocator, Vector&lt;std::pair&lt;JSC::MacroAssembler::Call, JSC::FunctionPtr&gt;&gt;&amp; callRegistry)
</del><ins>+    FunctionCall(JSC::MacroAssembler&amp; assembler, RegisterAllocator&amp; registerAllocator, StackAllocator&amp; stackAllocator, Vector&lt;std::pair&lt;JSC::MacroAssembler::Call, JSC::FunctionPtr&gt;, 32&gt;&amp; callRegistry)
</ins><span class="cx">         : m_assembler(assembler)
</span><span class="cx">         , m_registerAllocator(registerAllocator)
</span><span class="cx">         , m_stackAllocator(stackAllocator)
</span><span class="lines">@@ -167,7 +167,7 @@
</span><span class="cx">             if (RegisterAllocator::isCallerSavedRegister(registerID))
</span><span class="cx">                 m_savedRegisters.append(registerID);
</span><span class="cx">         }
</span><del>-        Vector&lt;StackAllocator::StackReference&gt; stackReferences = m_stackAllocator.push(m_savedRegisters);
</del><ins>+        Vector&lt;StackAllocator::StackReference, registerCount&gt; stackReferences = m_stackAllocator.push(m_savedRegisters);
</ins><span class="cx">         m_savedRegisterStackReferences.appendVector(stackReferences);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -180,7 +180,7 @@
</span><span class="cx">     JSC::MacroAssembler&amp; m_assembler;
</span><span class="cx">     RegisterAllocator&amp; m_registerAllocator;
</span><span class="cx">     StackAllocator&amp; m_stackAllocator;
</span><del>-    Vector&lt;std::pair&lt;JSC::MacroAssembler::Call, JSC::FunctionPtr&gt;&gt;&amp; m_callRegistry;
</del><ins>+    Vector&lt;std::pair&lt;JSC::MacroAssembler::Call, JSC::FunctionPtr&gt;, 32&gt;&amp; m_callRegistry;
</ins><span class="cx"> 
</span><span class="cx">     Vector&lt;JSC::MacroAssembler::RegisterID, registerCount&gt; m_savedRegisters;
</span><span class="cx">     Vector&lt;StackAllocator::StackReference, registerCount&gt; m_savedRegisterStackReferences;
</span></span></pre></div>
<a id="trunkSourceWebCorecssjitRegisterAllocatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/cssjit/RegisterAllocator.h (170696 => 170697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/cssjit/RegisterAllocator.h        2014-07-02 04:49:27 UTC (rev 170696)
+++ trunk/Source/WebCore/cssjit/RegisterAllocator.h        2014-07-02 04:49:39 UTC (rev 170697)
</span><span class="lines">@@ -205,7 +205,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    Deque&lt;JSC::MacroAssembler::RegisterID&gt; m_registers;
</del><ins>+    Deque&lt;JSC::MacroAssembler::RegisterID, registerCount&gt; m_registers;
</ins><span class="cx">     Vector&lt;JSC::MacroAssembler::RegisterID, registerCount&gt; m_allocatedRegisters;
</span><span class="cx">     Vector&lt;JSC::MacroAssembler::RegisterID, calleeSavedRegisterCount&gt; m_reservedCalleeSavedRegisters;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorecssjitSelectorCompilercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/cssjit/SelectorCompiler.cpp (170696 => 170697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/cssjit/SelectorCompiler.cpp        2014-07-02 04:49:27 UTC (rev 170696)
+++ trunk/Source/WebCore/cssjit/SelectorCompiler.cpp        2014-07-02 04:49:39 UTC (rev 170697)
</span><span class="lines">@@ -159,11 +159,11 @@
</span><span class="cx">     const QualifiedName* tagName;
</span><span class="cx">     const AtomicString* id;
</span><span class="cx">     const AtomicString* langFilter;
</span><del>-    Vector&lt;const AtomicStringImpl*, 1&gt; classNames;
</del><ins>+    Vector&lt;const AtomicStringImpl*, 32&gt; classNames;
</ins><span class="cx">     HashSet&lt;unsigned&gt; pseudoClasses;
</span><del>-    Vector&lt;JSC::FunctionPtr&gt; unoptimizedPseudoClasses;
-    Vector&lt;AttributeMatchingInfo&gt; attributes;
-    Vector&lt;std::pair&lt;int, int&gt;&gt; nthChildFilters;
</del><ins>+    Vector&lt;JSC::FunctionPtr, 32&gt; unoptimizedPseudoClasses;
+    Vector&lt;AttributeMatchingInfo, 32&gt; attributes;
+    Vector&lt;std::pair&lt;int, int&gt;, 32&gt; nthChildFilters;
</ins><span class="cx">     Vector&lt;SelectorFragment&gt; notFilters;
</span><span class="cx">     Vector&lt;Vector&lt;SelectorFragment&gt;&gt; anyFilters;
</span><span class="cx"> 
</span><span class="lines">@@ -192,8 +192,8 @@
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> typedef JSC::MacroAssembler Assembler;
</span><del>-typedef Vector&lt;SelectorFragment, 8&gt; SelectorFragmentList;
-typedef Vector&lt;TagNamePattern, 8&gt; TagNameList;
</del><ins>+typedef Vector&lt;SelectorFragment, 32&gt; SelectorFragmentList;
+typedef Vector&lt;TagNamePattern, 32&gt; TagNameList;
</ins><span class="cx"> 
</span><span class="cx"> class SelectorCodeGenerator {
</span><span class="cx"> public:
</span><span class="lines">@@ -265,12 +265,12 @@
</span><span class="cx"> 
</span><span class="cx">     bool generatePrologue();
</span><span class="cx">     void generateEpilogue();
</span><del>-    Vector&lt;StackAllocator::StackReference&gt; m_prologueStackReferences;
</del><ins>+    Vector&lt;StackAllocator::StackReference, registerCount&gt; m_prologueStackReferences;
</ins><span class="cx"> 
</span><span class="cx">     Assembler m_assembler;
</span><span class="cx">     RegisterAllocator m_registerAllocator;
</span><span class="cx">     StackAllocator m_stackAllocator;
</span><del>-    Vector&lt;std::pair&lt;Assembler::Call, JSC::FunctionPtr&gt;&gt; m_functionCalls;
</del><ins>+    Vector&lt;std::pair&lt;Assembler::Call, JSC::FunctionPtr&gt;, 32&gt; m_functionCalls;
</ins><span class="cx"> 
</span><span class="cx">     SelectorContext m_selectorContext;
</span><span class="cx">     FunctionType m_functionType;
</span><span class="lines">@@ -476,7 +476,7 @@
</span><span class="cx"> 
</span><span class="cx">     case CSSSelector::PseudoClassAny:
</span><span class="cx">         {
</span><del>-            Vector&lt;SelectorFragment&gt; anyFragments;
</del><ins>+            Vector&lt;SelectorFragment, 32&gt; anyFragments;
</ins><span class="cx">             FunctionType functionType = FunctionType::SimpleSelectorChecker;
</span><span class="cx">             for (const CSSSelector* rootSelector = selector.selectorList()-&gt;first(); rootSelector; rootSelector = CSSSelectorList::next(rootSelector)) {
</span><span class="cx">                 SelectorFragmentList fragmentList;
</span><span class="lines">@@ -1166,7 +1166,7 @@
</span><span class="cx"> 
</span><span class="cx"> void SelectorCodeGenerator::generateSelectorChecker()
</span><span class="cx"> {
</span><del>-    Vector&lt;StackAllocator::StackReference&gt; calleeSavedRegisterStackReferences;
</del><ins>+    Vector&lt;StackAllocator::StackReference, calleeSavedRegisterCount&gt; calleeSavedRegisterStackReferences;
</ins><span class="cx">     bool reservedCalleeSavedRegisters = false;
</span><span class="cx">     unsigned availableRegisterCount = m_registerAllocator.availableRegisterCount();
</span><span class="cx">     unsigned minimumRegisterCountForAttributes = minimumRegisterRequirements(m_selectorFragments);
</span><span class="lines">@@ -2582,7 +2582,7 @@
</span><span class="cx">     Assembler::RegisterID parentElement = m_registerAllocator.allocateRegister();
</span><span class="cx">     generateWalkToParentElement(failureCases, parentElement);
</span><span class="cx"> 
</span><del>-    Vector&lt;std::pair&lt;int, int&gt;&gt; validSubsetFilters;
</del><ins>+    Vector&lt;std::pair&lt;int, int&gt;, 32&gt; validSubsetFilters;
</ins><span class="cx">     validSubsetFilters.reserveInitialCapacity(fragment.nthChildFilters.size());
</span><span class="cx">     for (const auto&amp; slot : fragment.nthChildFilters) {
</span><span class="cx">         int a = slot.first;
</span></span></pre></div>
<a id="trunkSourceWebCorecssjitStackAllocatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/cssjit/StackAllocator.h (170696 => 170697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/cssjit/StackAllocator.h        2014-07-02 04:49:27 UTC (rev 170696)
+++ trunk/Source/WebCore/cssjit/StackAllocator.h        2014-07-02 04:49:39 UTC (rev 170697)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(CSS_SELECTOR_JIT)
</span><span class="cx"> 
</span><ins>+#include &quot;RegisterAllocator.h&quot;
</ins><span class="cx"> #include &lt;JavaScriptCore/MacroAssembler.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -68,21 +69,20 @@
</span><span class="cx">         return StackReference(m_offsetFromTop);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Vector&lt;StackReference&gt; push(const Vector&lt;JSC::MacroAssembler::RegisterID&gt;&amp; registerIDs)
</del><ins>+    Vector&lt;StackReference, registerCount&gt; push(const Vector&lt;JSC::MacroAssembler::RegisterID&gt;&amp; registerIDs)
</ins><span class="cx">     {
</span><span class="cx">         RELEASE_ASSERT(!m_hasFunctionCallPadding);
</span><del>-        unsigned registerCount = registerIDs.size();
-        Vector&lt;StackReference&gt; stackReferences;
-        stackReferences.reserveInitialCapacity(registerCount);
</del><ins>+        Vector&lt;StackReference, registerCount&gt; stackReferences;
</ins><span class="cx"> #if CPU(ARM64)
</span><del>-        for (unsigned i = 0; i &lt; registerCount - 1; i += 2) {
</del><ins>+        unsigned pushRegisterCount = registerIDs.size();
+        for (unsigned i = 0; i &lt; pushRegisterCount - 1; i += 2) {
</ins><span class="cx">             m_assembler.pushPair(registerIDs[i + 1], registerIDs[i]);
</span><span class="cx">             m_offsetFromTop += stackUnitInBytes();
</span><span class="cx">             stackReferences.append(StackReference(m_offsetFromTop - stackUnitInBytes() / 2));
</span><span class="cx">             stackReferences.append(StackReference(m_offsetFromTop));
</span><span class="cx">         }
</span><del>-        if (registerCount % 2)
-            stackReferences.append(push(registerIDs[registerCount - 1]));
</del><ins>+        if (pushRegisterCount % 2)
+            stackReferences.append(push(registerIDs[pushRegisterCount - 1]));
</ins><span class="cx"> #else
</span><span class="cx">         for (auto registerID : registerIDs)
</span><span class="cx">             stackReferences.append(push(registerID));
</span><span class="lines">@@ -102,14 +102,14 @@
</span><span class="cx">     {
</span><span class="cx">         RELEASE_ASSERT(!m_hasFunctionCallPadding);
</span><span class="cx"> 
</span><del>-        unsigned registerCount = registerIDs.size();
-        RELEASE_ASSERT(stackReferences.size() == registerCount);
</del><ins>+        unsigned popRegisterCount = registerIDs.size();
+        RELEASE_ASSERT(stackReferences.size() == popRegisterCount);
</ins><span class="cx"> #if CPU(ARM64)
</span><del>-        ASSERT(m_offsetFromTop &gt;= stackUnitInBytes() * ((registerCount + 1) / 2));
-        unsigned registerCountOdd = registerCount % 2;
-        if (registerCountOdd)
-            pop(stackReferences[registerCount - 1], registerIDs[registerCount - 1]);
-        for (unsigned i = registerCount - registerCountOdd; i &gt; 0; i -= 2) {
</del><ins>+        ASSERT(m_offsetFromTop &gt;= stackUnitInBytes() * ((popRegisterCount + 1) / 2));
+        unsigned popRegisterCountOdd = popRegisterCount % 2;
+        if (popRegisterCountOdd)
+            pop(stackReferences[popRegisterCount - 1], registerIDs[popRegisterCount - 1]);
+        for (unsigned i = popRegisterCount - popRegisterCountOdd; i &gt; 0; i -= 2) {
</ins><span class="cx">             RELEASE_ASSERT(stackReferences[i - 1] == m_offsetFromTop);
</span><span class="cx">             RELEASE_ASSERT(stackReferences[i - 2] == m_offsetFromTop - stackUnitInBytes() / 2);
</span><span class="cx">             RELEASE_ASSERT(m_offsetFromTop &gt;= stackUnitInBytes());
</span><span class="lines">@@ -117,8 +117,8 @@
</span><span class="cx">             m_assembler.popPair(registerIDs[i - 1], registerIDs[i - 2]);
</span><span class="cx">         }
</span><span class="cx"> #else
</span><del>-        ASSERT(m_offsetFromTop &gt;= stackUnitInBytes() * registerCount);
-        for (unsigned i = registerCount; i &gt; 0; --i)
</del><ins>+        ASSERT(m_offsetFromTop &gt;= stackUnitInBytes() * popRegisterCount);
+        for (unsigned i = popRegisterCount; i &gt; 0; --i)
</ins><span class="cx">             pop(stackReferences[i - 1], registerIDs[i - 1]);
</span><span class="cx"> #endif
</span><span class="cx">     }
</span></span></pre>
</div>
</div>

</body>
</html>