<!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>[194848] 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/194848">194848</a></dd>
<dt>Author</dt> <dd>akling@apple.com</dd>
<dt>Date</dt> <dd>2016-01-11 04:23:57 -0800 (Mon, 11 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Source/WebCore:
CSSValuePool should use nonfragmented storage for eternal caches.
&lt;https://webkit.org/b/152960&gt;

Reviewed by Antti Koivisto.

Store all of the common cached CSS value objects in contiguous arrays
instead of lazily allocating them on the heap.

This reduces heap fragmentation (win) and removes indirection (win)

* css/CSSInheritedValue.h:
* css/CSSInitialValue.h:
* css/CSSPrimitiveValue.h:
* css/CSSRevertValue.h:
* css/CSSUnsetValue.h:
* css/CSSValuePool.cpp:
(WebCore::CSSValuePool::CSSValuePool):
(WebCore::CSSValuePool::createIdentifierValue):
(WebCore::CSSValuePool::createColorValue):
(WebCore::CSSValuePool::createValue):
(WebCore::CSSValuePool::drain): Deleted.
* css/CSSValuePool.h:
(WebCore::CSSValuePool::createInheritedValue):
(WebCore::CSSValuePool::createImplicitInitialValue):
(WebCore::CSSValuePool::createExplicitInitialValue):
(WebCore::CSSValuePool::createUnsetValue):
(WebCore::CSSValuePool::createRevertValue):

Source/WTF:
NeverDestroyed should relax adoption requirements on all RefCountedBase subclasses.
&lt;https://webkit.org/b/152960&gt;

Reviewed by Antti Koivisto.

Instead of relaxing on subclasses of RefCounted&lt;T&gt;, relax on subclasses of RefCountedBase.
This allows e.g NeverDestroyed&lt;CSSPrimitiveValue&gt; to relax its pointee despite the class
hierarchy starting with RefCounted&lt;CSSValue&gt; (not RefCounted&lt;CSSPrimitiveValue&gt;.)

* wtf/NeverDestroyed.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfNeverDestroyedh">trunk/Source/WTF/wtf/NeverDestroyed.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssCSSInheritedValueh">trunk/Source/WebCore/css/CSSInheritedValue.h</a></li>
<li><a href="#trunkSourceWebCorecssCSSInitialValueh">trunk/Source/WebCore/css/CSSInitialValue.h</a></li>
<li><a href="#trunkSourceWebCorecssCSSPrimitiveValueh">trunk/Source/WebCore/css/CSSPrimitiveValue.h</a></li>
<li><a href="#trunkSourceWebCorecssCSSRevertValueh">trunk/Source/WebCore/css/CSSRevertValue.h</a></li>
<li><a href="#trunkSourceWebCorecssCSSUnsetValueh">trunk/Source/WebCore/css/CSSUnsetValue.h</a></li>
<li><a href="#trunkSourceWebCorecssCSSValuePoolcpp">trunk/Source/WebCore/css/CSSValuePool.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSValuePoolh">trunk/Source/WebCore/css/CSSValuePool.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (194847 => 194848)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2016-01-11 11:39:22 UTC (rev 194847)
+++ trunk/Source/WTF/ChangeLog        2016-01-11 12:23:57 UTC (rev 194848)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-01-11  Andreas Kling  &lt;akling@apple.com&gt;
+
+        NeverDestroyed should relax adoption requirements on all RefCountedBase subclasses.
+        &lt;https://webkit.org/b/152960&gt;
+
+        Reviewed by Antti Koivisto.
+
+        Instead of relaxing on subclasses of RefCounted&lt;T&gt;, relax on subclasses of RefCountedBase.
+        This allows e.g NeverDestroyed&lt;CSSPrimitiveValue&gt; to relax its pointee despite the class
+        hierarchy starting with RefCounted&lt;CSSValue&gt; (not RefCounted&lt;CSSPrimitiveValue&gt;.)
+
+        * wtf/NeverDestroyed.h:
+
</ins><span class="cx"> 2016-01-10  Saam barati  &lt;sbarati@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Implement a sampling profiler
</span></span></pre></div>
<a id="trunkSourceWTFwtfNeverDestroyedh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/NeverDestroyed.h (194847 => 194848)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/NeverDestroyed.h        2016-01-11 11:39:22 UTC (rev 194847)
+++ trunk/Source/WTF/wtf/NeverDestroyed.h        2016-01-11 12:23:57 UTC (rev 194848)
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx">     // and hand out chunks of it to NeverDestroyed instead, to reduce fragmentation.
</span><span class="cx">     typename std::aligned_storage&lt;sizeof(T), std::alignment_of&lt;T&gt;::value&gt;::type m_storage;
</span><span class="cx"> 
</span><del>-    template &lt;typename PtrType, bool ShouldRelax = std::is_base_of&lt;RefCounted&lt;PtrType&gt;, PtrType&gt;::value&gt; struct MaybeRelax {
</del><ins>+    template &lt;typename PtrType, bool ShouldRelax = std::is_base_of&lt;RefCountedBase, PtrType&gt;::value&gt; struct MaybeRelax {
</ins><span class="cx">         explicit MaybeRelax(PtrType*) { }
</span><span class="cx">     };
</span><span class="cx">     template &lt;typename PtrType&gt; struct MaybeRelax&lt;PtrType, true&gt; {
</span><span class="lines">@@ -110,7 +110,7 @@
</span><span class="cx">     // and hand out chunks of it to NeverDestroyed instead, to reduce fragmentation.
</span><span class="cx">     typename std::aligned_storage&lt;sizeof(T), std::alignment_of&lt;T&gt;::value&gt;::type m_storage;
</span><span class="cx"> 
</span><del>-    template &lt;typename PtrType, bool ShouldRelax = std::is_base_of&lt;RefCounted&lt;PtrType&gt;, PtrType&gt;::value&gt; struct MaybeRelax {
</del><ins>+    template &lt;typename PtrType, bool ShouldRelax = std::is_base_of&lt;RefCountedBase, PtrType&gt;::value&gt; struct MaybeRelax {
</ins><span class="cx">         explicit MaybeRelax(PtrType*) { }
</span><span class="cx">     };
</span><span class="cx">     template &lt;typename PtrType&gt; struct MaybeRelax&lt;PtrType, true&gt; {
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (194847 => 194848)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-01-11 11:39:22 UTC (rev 194847)
+++ trunk/Source/WebCore/ChangeLog        2016-01-11 12:23:57 UTC (rev 194848)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2016-01-11  Andreas Kling  &lt;akling@apple.com&gt;
+
+        CSSValuePool should use nonfragmented storage for eternal caches.
+        &lt;https://webkit.org/b/152960&gt;
+
+        Reviewed by Antti Koivisto.
+
+        Store all of the common cached CSS value objects in contiguous arrays
+        instead of lazily allocating them on the heap.
+
+        This reduces heap fragmentation (win) and removes indirection (win)
+
+        * css/CSSInheritedValue.h:
+        * css/CSSInitialValue.h:
+        * css/CSSPrimitiveValue.h:
+        * css/CSSRevertValue.h:
+        * css/CSSUnsetValue.h:
+        * css/CSSValuePool.cpp:
+        (WebCore::CSSValuePool::CSSValuePool):
+        (WebCore::CSSValuePool::createIdentifierValue):
+        (WebCore::CSSValuePool::createColorValue):
+        (WebCore::CSSValuePool::createValue):
+        (WebCore::CSSValuePool::drain): Deleted.
+        * css/CSSValuePool.h:
+        (WebCore::CSSValuePool::createInheritedValue):
+        (WebCore::CSSValuePool::createImplicitInitialValue):
+        (WebCore::CSSValuePool::createExplicitInitialValue):
+        (WebCore::CSSValuePool::createUnsetValue):
+        (WebCore::CSSValuePool::createRevertValue):
+
</ins><span class="cx"> 2016-01-11  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] Cleanup RenderThemeGtk
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSInheritedValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSInheritedValue.h (194847 => 194848)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSInheritedValue.h        2016-01-11 11:39:22 UTC (rev 194847)
+++ trunk/Source/WebCore/css/CSSInheritedValue.h        2016-01-11 12:23:57 UTC (rev 194848)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx"> #define CSSInheritedValue_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CSSValue.h&quot;
</span><del>-#include &lt;wtf/PassRefPtr.h&gt;
</del><ins>+#include &lt;wtf/NeverDestroyed.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -38,6 +38,8 @@
</span><span class="cx">     bool equals(const CSSInheritedValue&amp;) const { return true; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    friend class LazyNeverDestroyed&lt;CSSInheritedValue&gt;;
+
</ins><span class="cx">     CSSInheritedValue()
</span><span class="cx">         : CSSValue(InheritedClass)
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSInitialValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSInitialValue.h (194847 => 194848)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSInitialValue.h        2016-01-11 11:39:22 UTC (rev 194847)
+++ trunk/Source/WebCore/css/CSSInitialValue.h        2016-01-11 12:23:57 UTC (rev 194848)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx"> #define CSSInitialValue_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CSSValue.h&quot;
</span><del>-#include &lt;wtf/PassRefPtr.h&gt;
</del><ins>+#include &lt;wtf/NeverDestroyed.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -44,6 +44,8 @@
</span><span class="cx">     bool equals(const CSSInitialValue&amp;) const { return true; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    friend class LazyNeverDestroyed&lt;CSSInitialValue&gt;;
+
</ins><span class="cx">     CSSInitialValue(bool implicit)
</span><span class="cx">         : CSSValue(InitialClass)
</span><span class="cx">         , m_isImplicit(implicit)
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSPrimitiveValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.h (194847 => 194848)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSPrimitiveValue.h        2016-01-11 11:39:22 UTC (rev 194847)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.h        2016-01-11 12:23:57 UTC (rev 194848)
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> #include &lt;utility&gt;
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><span class="cx"> #include &lt;wtf/MathExtras.h&gt;
</span><del>-#include &lt;wtf/PassRefPtr.h&gt;
</del><ins>+#include &lt;wtf/NeverDestroyed.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -383,6 +383,9 @@
</span><span class="cx"> 
</span><span class="cx">     static double computeNonCalcLengthDouble(const CSSToLengthConversionData&amp;, unsigned short primitiveType, double value);
</span><span class="cx"> private:
</span><ins>+    friend class CSSValuePool;
+    friend class LazyNeverDestroyed&lt;CSSPrimitiveValue&gt;;
+
</ins><span class="cx">     CSSPrimitiveValue(CSSValueID);
</span><span class="cx">     CSSPrimitiveValue(CSSPropertyID);
</span><span class="cx">     // FIXME: int vs. unsigned overloading is too subtle to distinguish the color and operator cases.
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSRevertValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSRevertValue.h (194847 => 194848)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSRevertValue.h        2016-01-11 11:39:22 UTC (rev 194847)
+++ trunk/Source/WebCore/css/CSSRevertValue.h        2016-01-11 12:23:57 UTC (rev 194848)
</span><span class="lines">@@ -27,7 +27,7 @@
</span><span class="cx"> #define CSSRevertValue_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CSSValue.h&quot;
</span><del>-#include &lt;wtf/PassRefPtr.h&gt;
</del><ins>+#include &lt;wtf/NeverDestroyed.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -43,6 +43,8 @@
</span><span class="cx">     bool equals(const CSSRevertValue&amp;) const { return true; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    friend class LazyNeverDestroyed&lt;CSSRevertValue&gt;;
+
</ins><span class="cx">     CSSRevertValue()
</span><span class="cx">         : CSSValue(RevertClass)
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSUnsetValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSUnsetValue.h (194847 => 194848)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSUnsetValue.h        2016-01-11 11:39:22 UTC (rev 194847)
+++ trunk/Source/WebCore/css/CSSUnsetValue.h        2016-01-11 12:23:57 UTC (rev 194848)
</span><span class="lines">@@ -27,7 +27,7 @@
</span><span class="cx"> #define CSSUnsetValue_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CSSValue.h&quot;
</span><del>-#include &lt;wtf/PassRefPtr.h&gt;
</del><ins>+#include &lt;wtf/NeverDestroyed.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -43,6 +43,8 @@
</span><span class="cx">     bool equals(const CSSUnsetValue&amp;) const { return true; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    friend class LazyNeverDestroyed&lt;CSSUnsetValue&gt;;
+
</ins><span class="cx">     CSSUnsetValue()
</span><span class="cx">         : CSSValue(UnsetClass)
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSValuePoolcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSValuePool.cpp (194847 => 194848)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSValuePool.cpp        2016-01-11 11:39:22 UTC (rev 194847)
+++ trunk/Source/WebCore/css/CSSValuePool.cpp        2016-01-11 12:23:57 UTC (rev 194848)
</span><span class="lines">@@ -41,26 +41,31 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CSSValuePool::CSSValuePool()
</span><del>-    : m_inheritedValue(CSSInheritedValue::create())
-    , m_implicitInitialValue(CSSInitialValue::createImplicit())
-    , m_explicitInitialValue(CSSInitialValue::createExplicit())
-    , m_unsetValue(CSSUnsetValue::create())
-    , m_revertValue(CSSRevertValue::create())
-    , m_colorTransparent(CSSPrimitiveValue::createColor(Color::transparent))
-    , m_colorWhite(CSSPrimitiveValue::createColor(Color::white))
-    , m_colorBlack(CSSPrimitiveValue::createColor(Color::black))
</del><span class="cx"> {
</span><ins>+    m_inheritedValue.construct();
+    m_implicitInitialValue.construct(true);
+    m_explicitInitialValue.construct(false);
+    m_unsetValue.construct();
+    m_revertValue.construct();
+
+    m_transparentColor.construct(Color::transparent);
+    m_whiteColor.construct(Color::white);
+    m_blackColor.construct(Color::black);
+
+    for (unsigned i = 0; i &lt; numCSSValueKeywords; ++i)
+        m_identifierValues[i].construct(static_cast&lt;CSSValueID&gt;(i));
+
+    for (unsigned i = 0; i &lt; (maximumCacheableIntegerValue + 1); ++i) {
+        m_pixelValues[i].construct(i, CSSPrimitiveValue::CSS_PX);
+        m_percentValues[i].construct(i, CSSPrimitiveValue::CSS_PERCENTAGE);
+        m_numberValues[i].construct(i, CSSPrimitiveValue::CSS_NUMBER);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Ref&lt;CSSPrimitiveValue&gt; CSSValuePool::createIdentifierValue(CSSValueID ident)
</span><span class="cx"> {
</span><del>-    if (!ident)
-        return CSSPrimitiveValue::createIdentifier(ident);
-
-    RELEASE_ASSERT(ident &gt; 0 &amp;&amp; ident &lt; numCSSValueKeywords);
-    if (!m_identifierValueCache[ident])
-        m_identifierValueCache[ident] = CSSPrimitiveValue::createIdentifier(ident);
-    return *m_identifierValueCache[ident];
</del><ins>+    RELEASE_ASSERT(ident &gt;= 0 &amp;&amp; ident &lt; numCSSValueKeywords);
+    return m_identifierValues[ident].get();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Ref&lt;CSSPrimitiveValue&gt; CSSValuePool::createIdentifierValue(CSSPropertyID ident)
</span><span class="lines">@@ -72,12 +77,12 @@
</span><span class="cx"> {
</span><span class="cx">     // These are the empty and deleted values of the hash table.
</span><span class="cx">     if (rgbValue == Color::transparent)
</span><del>-        return m_colorTransparent.copyRef();
</del><ins>+        return m_transparentColor.get();
</ins><span class="cx">     if (rgbValue == Color::white)
</span><del>-        return m_colorWhite.copyRef();
</del><ins>+        return m_whiteColor.get();
</ins><span class="cx">     // Just because it is common.
</span><span class="cx">     if (rgbValue == Color::black)
</span><del>-        return m_colorBlack.copyRef();
</del><ins>+        return m_blackColor.get();
</ins><span class="cx"> 
</span><span class="cx">     // Remove one entry at random if the cache grows too large.
</span><span class="cx">     const int maximumColorCacheSize = 512;
</span><span class="lines">@@ -101,24 +106,16 @@
</span><span class="cx">     if (value != intValue)
</span><span class="cx">         return CSSPrimitiveValue::create(value, type);
</span><span class="cx"> 
</span><del>-    RefPtr&lt;CSSPrimitiveValue&gt;* cache;
</del><span class="cx">     switch (type) {
</span><span class="cx">     case CSSPrimitiveValue::CSS_PX:
</span><del>-        cache = m_pixelValueCache;
-        break;
</del><ins>+        return m_pixelValues[intValue].get();
</ins><span class="cx">     case CSSPrimitiveValue::CSS_PERCENTAGE:
</span><del>-        cache = m_percentValueCache;
-        break;
</del><ins>+        return m_percentValues[intValue].get();
</ins><span class="cx">     case CSSPrimitiveValue::CSS_NUMBER:
</span><del>-        cache = m_numberValueCache;
-        break;
</del><ins>+        return m_numberValues[intValue].get();
</ins><span class="cx">     default:
</span><span class="cx">         return CSSPrimitiveValue::create(value, type);
</span><span class="cx">     }
</span><del>-
-    if (!cache[intValue])
-        cache[intValue] = CSSPrimitiveValue::create(value, type);
-    return *cache[intValue];
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Ref&lt;CSSPrimitiveValue&gt; CSSValuePool::createFontFamilyValue(const String&amp; familyName, FromSystemFontID fromSystemFontID)
</span><span class="lines">@@ -153,15 +150,6 @@
</span><span class="cx">     m_colorValueCache.clear();
</span><span class="cx">     m_fontFaceValueCache.clear();
</span><span class="cx">     m_fontFamilyValueCache.clear();
</span><del>-
-    for (int i = 0; i &lt; numCSSValueKeywords; ++i)
-        m_identifierValueCache[i] = nullptr;
-
-    for (int i = 0; i &lt; maximumCacheableIntegerValue; ++i) {
-        m_pixelValueCache[i] = nullptr;
-        m_percentValueCache[i] = nullptr;
-        m_numberValueCache[i] = nullptr;
-    }
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSValuePoolh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSValuePool.h (194847 => 194848)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSValuePool.h        2016-01-11 11:39:22 UTC (rev 194847)
+++ trunk/Source/WebCore/css/CSSValuePool.h        2016-01-11 12:23:57 UTC (rev 194848)
</span><span class="lines">@@ -53,11 +53,11 @@
</span><span class="cx"> 
</span><span class="cx">     PassRefPtr&lt;CSSValueList&gt; createFontFaceValue(const AtomicString&amp;);
</span><span class="cx">     Ref&lt;CSSPrimitiveValue&gt; createFontFamilyValue(const String&amp;, FromSystemFontID = FromSystemFontID::No);
</span><del>-    Ref&lt;CSSInheritedValue&gt; createInheritedValue() { return m_inheritedValue.copyRef(); }
-    Ref&lt;CSSInitialValue&gt; createImplicitInitialValue() { return m_implicitInitialValue.copyRef(); }
-    Ref&lt;CSSInitialValue&gt; createExplicitInitialValue() { return m_explicitInitialValue.copyRef(); }
-    Ref&lt;CSSUnsetValue&gt; createUnsetValue() { return m_unsetValue.copyRef(); }
-    Ref&lt;CSSRevertValue&gt; createRevertValue() { return m_revertValue.copyRef(); }
</del><ins>+    Ref&lt;CSSInheritedValue&gt; createInheritedValue() { return m_inheritedValue.get(); }
+    Ref&lt;CSSInitialValue&gt; createImplicitInitialValue() { return m_implicitInitialValue.get(); }
+    Ref&lt;CSSInitialValue&gt; createExplicitInitialValue() { return m_explicitInitialValue.get(); }
+    Ref&lt;CSSUnsetValue&gt; createUnsetValue() { return m_unsetValue.get(); }
+    Ref&lt;CSSRevertValue&gt; createRevertValue() { return m_revertValue.get(); }
</ins><span class="cx">     Ref&lt;CSSPrimitiveValue&gt; createIdentifierValue(CSSValueID identifier);
</span><span class="cx">     Ref&lt;CSSPrimitiveValue&gt; createIdentifierValue(CSSPropertyID identifier);
</span><span class="cx">     Ref&lt;CSSPrimitiveValue&gt; createColorValue(unsigned rgbValue);
</span><span class="lines">@@ -72,26 +72,9 @@
</span><span class="cx"> private:
</span><span class="cx">     CSSValuePool();
</span><span class="cx"> 
</span><del>-    Ref&lt;CSSInheritedValue&gt; m_inheritedValue;
-    Ref&lt;CSSInitialValue&gt; m_implicitInitialValue;
-    Ref&lt;CSSInitialValue&gt; m_explicitInitialValue;
-    Ref&lt;CSSUnsetValue&gt; m_unsetValue;
-    Ref&lt;CSSRevertValue&gt; m_revertValue;
-
-    RefPtr&lt;CSSPrimitiveValue&gt; m_identifierValueCache[numCSSValueKeywords];
-
</del><span class="cx">     typedef HashMap&lt;unsigned, RefPtr&lt;CSSPrimitiveValue&gt;&gt; ColorValueCache;
</span><span class="cx">     ColorValueCache m_colorValueCache;
</span><del>-    Ref&lt;CSSPrimitiveValue&gt; m_colorTransparent;
-    Ref&lt;CSSPrimitiveValue&gt; m_colorWhite;
-    Ref&lt;CSSPrimitiveValue&gt; m_colorBlack;
</del><span class="cx"> 
</span><del>-    static const int maximumCacheableIntegerValue = 255;
-
-    RefPtr&lt;CSSPrimitiveValue&gt; m_pixelValueCache[maximumCacheableIntegerValue + 1];
-    RefPtr&lt;CSSPrimitiveValue&gt; m_percentValueCache[maximumCacheableIntegerValue + 1];
-    RefPtr&lt;CSSPrimitiveValue&gt; m_numberValueCache[maximumCacheableIntegerValue + 1];
-
</del><span class="cx">     typedef HashMap&lt;AtomicString, RefPtr&lt;CSSValueList&gt;&gt; FontFaceValueCache;
</span><span class="cx">     FontFaceValueCache m_fontFaceValueCache;
</span><span class="cx"> 
</span><span class="lines">@@ -99,6 +82,23 @@
</span><span class="cx">     FontFamilyValueCache m_fontFamilyValueCache;
</span><span class="cx"> 
</span><span class="cx">     friend class WTF::NeverDestroyed&lt;CSSValuePool&gt;;
</span><ins>+
+    LazyNeverDestroyed&lt;CSSInheritedValue&gt; m_inheritedValue;
+    LazyNeverDestroyed&lt;CSSInitialValue&gt; m_implicitInitialValue;
+    LazyNeverDestroyed&lt;CSSInitialValue&gt; m_explicitInitialValue;
+    LazyNeverDestroyed&lt;CSSUnsetValue&gt; m_unsetValue;
+    LazyNeverDestroyed&lt;CSSRevertValue&gt; m_revertValue;
+
+    LazyNeverDestroyed&lt;CSSPrimitiveValue&gt; m_transparentColor;
+    LazyNeverDestroyed&lt;CSSPrimitiveValue&gt; m_whiteColor;
+    LazyNeverDestroyed&lt;CSSPrimitiveValue&gt; m_blackColor;
+
+    static const int maximumCacheableIntegerValue = 255;
+
+    LazyNeverDestroyed&lt;CSSPrimitiveValue&gt; m_pixelValues[maximumCacheableIntegerValue + 1];
+    LazyNeverDestroyed&lt;CSSPrimitiveValue&gt; m_percentValues[maximumCacheableIntegerValue + 1];
+    LazyNeverDestroyed&lt;CSSPrimitiveValue&gt; m_numberValues[maximumCacheableIntegerValue + 1];
+    LazyNeverDestroyed&lt;CSSPrimitiveValue&gt; m_identifierValues[numCSSValueKeywords];
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>