<!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>[179743] 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/179743">179743</a></dd>
<dt>Author</dt> <dd>akling@apple.com</dd>
<dt>Date</dt> <dd>2015-02-06 02:03:56 -0800 (Fri, 06 Feb 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove WTF::fastMallocGoodSize().
&lt;https://webkit.org/b/141020&gt;

Reviewed by Anders Carlsson.

Source/JavaScriptCore:

* assembler/AssemblerBuffer.h:
(JSC::AssemblerData::AssemblerData):
(JSC::AssemblerData::grow):

Source/WTF:

bmalloc's good-size API just returns exactly whatever you pass it,
so it's of no utility to us anymore.

This gets rid of a bunch of pointless out-of-line calls in Vector
construction and growth.

* wtf/Compression.cpp:
(WTF::GenericCompressedData::create):
* wtf/FastMalloc.cpp:
(WTF::fastMallocGoodSize): Deleted.
* wtf/FastMalloc.h:
* wtf/Vector.h:
(WTF::VectorBufferBase::allocateBuffer):
(WTF::VectorBufferBase::tryAllocateBuffer):
(WTF::VectorBufferBase::reallocateBuffer):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreassemblerAssemblerBufferh">trunk/Source/JavaScriptCore/assembler/AssemblerBuffer.h</a></li>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfCompressioncpp">trunk/Source/WTF/wtf/Compression.cpp</a></li>
<li><a href="#trunkSourceWTFwtfFastMalloccpp">trunk/Source/WTF/wtf/FastMalloc.cpp</a></li>
<li><a href="#trunkSourceWTFwtfFastMalloch">trunk/Source/WTF/wtf/FastMalloc.h</a></li>
<li><a href="#trunkSourceWTFwtfVectorh">trunk/Source/WTF/wtf/Vector.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (179742 => 179743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-02-06 08:31:30 UTC (rev 179742)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-02-06 10:03:56 UTC (rev 179743)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2015-02-06  Andreas Kling  &lt;akling@apple.com&gt;
+
+        Remove WTF::fastMallocGoodSize().
+        &lt;https://webkit.org/b/141020&gt;
+
+        Reviewed by Anders Carlsson.
+
+        * assembler/AssemblerBuffer.h:
+        (JSC::AssemblerData::AssemblerData):
+        (JSC::AssemblerData::grow):
+
</ins><span class="cx"> 2015-02-05  Michael Saboff  &lt;msaboff@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         CodeCache is not thread safe when adding the same source from two different threads
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreassemblerAssemblerBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/assembler/AssemblerBuffer.h (179742 => 179743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/assembler/AssemblerBuffer.h        2015-02-06 08:31:30 UTC (rev 179742)
+++ trunk/Source/JavaScriptCore/assembler/AssemblerBuffer.h        2015-02-06 10:03:56 UTC (rev 179743)
</span><span class="lines">@@ -68,9 +68,9 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         AssemblerData(unsigned initialCapacity)
</span><ins>+            : m_buffer(static_cast&lt;char*&gt;(fastMalloc(initialCapacity)))
+            , m_capacity(initialCapacity)
</ins><span class="cx">         {
</span><del>-            m_capacity = fastMallocGoodSize(initialCapacity);
-            m_buffer = static_cast&lt;char*&gt;(fastMalloc(m_capacity));
</del><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         AssemblerData(AssemblerData&amp;&amp; other)
</span><span class="lines">@@ -101,7 +101,7 @@
</span><span class="cx"> 
</span><span class="cx">         void grow(unsigned extraCapacity = 0)
</span><span class="cx">         {
</span><del>-            m_capacity = fastMallocGoodSize(m_capacity + m_capacity / 2 + extraCapacity);
</del><ins>+            m_capacity = m_capacity + m_capacity / 2 + extraCapacity;
</ins><span class="cx">             m_buffer = static_cast&lt;char*&gt;(fastRealloc(m_buffer, m_capacity));
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (179742 => 179743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2015-02-06 08:31:30 UTC (rev 179742)
+++ trunk/Source/WTF/ChangeLog        2015-02-06 10:03:56 UTC (rev 179743)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2015-02-06  Andreas Kling  &lt;akling@apple.com&gt;
+
+        Remove WTF::fastMallocGoodSize().
+        &lt;https://webkit.org/b/141020&gt;
+
+        Reviewed by Anders Carlsson.
+
+        bmalloc's good-size API just returns exactly whatever you pass it,
+        so it's of no utility to us anymore.
+
+        This gets rid of a bunch of pointless out-of-line calls in Vector
+        construction and growth.
+
+        * wtf/Compression.cpp:
+        (WTF::GenericCompressedData::create):
+        * wtf/FastMalloc.cpp:
+        (WTF::fastMallocGoodSize): Deleted.
+        * wtf/FastMalloc.h:
+        * wtf/Vector.h:
+        (WTF::VectorBufferBase::allocateBuffer):
+        (WTF::VectorBufferBase::tryAllocateBuffer):
+        (WTF::VectorBufferBase::reallocateBuffer):
+
</ins><span class="cx"> 2015-02-05  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt; and Xabier Rodriguez Calvar &lt;calvaris@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Streams API] Implement a barebone ReadableStream interface
</span></span></pre></div>
<a id="trunkSourceWTFwtfCompressioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Compression.cpp (179742 => 179743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Compression.cpp        2015-02-06 08:31:30 UTC (rev 179742)
+++ trunk/Source/WTF/wtf/Compression.cpp        2015-02-06 10:03:56 UTC (rev 179743)
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx">     stream.next_in = const_cast&lt;uint8_t*&gt;(data);
</span><span class="cx"> 
</span><span class="cx">     size_t currentOffset = OBJECT_OFFSETOF(GenericCompressedData, m_data);
</span><del>-    size_t currentCapacity = fastMallocGoodSize(MinimumSize);
</del><ins>+    size_t currentCapacity = MinimumSize;
</ins><span class="cx">     Bytef* compressedData = static_cast&lt;Bytef*&gt;(fastMalloc(currentCapacity));
</span><span class="cx">     memset(compressedData, 0, sizeof(GenericCompressedData));
</span><span class="cx">     stream.next_out = compressedData + currentOffset;
</span><span class="lines">@@ -94,7 +94,6 @@
</span><span class="cx">                 // data in the future.
</span><span class="cx">                 newCapacity = std::max(static_cast&lt;size_t&gt;(expectedSize + 8), currentCapacity + 8);
</span><span class="cx">             }
</span><del>-            newCapacity = fastMallocGoodSize(newCapacity);
</del><span class="cx">             if (newCapacity &gt;= dataLength)
</span><span class="cx">                 goto fail;
</span><span class="cx">             compressedData = static_cast&lt;Bytef*&gt;(fastRealloc(compressedData, newCapacity));
</span></span></pre></div>
<a id="trunkSourceWTFwtfFastMalloccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/FastMalloc.cpp (179742 => 179743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/FastMalloc.cpp        2015-02-06 08:31:30 UTC (rev 179742)
+++ trunk/Source/WTF/wtf/FastMalloc.cpp        2015-02-06 10:03:56 UTC (rev 179743)
</span><span class="lines">@@ -153,15 +153,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WTF {
</span><span class="cx"> 
</span><del>-size_t fastMallocGoodSize(size_t bytes)
-{
-#if OS(DARWIN)
-    return malloc_good_size(bytes);
-#else
-    return bytes;
-#endif
-}
-
</del><span class="cx"> #if OS(WINDOWS)
</span><span class="cx"> 
</span><span class="cx"> void* fastAlignedMalloc(size_t alignment, size_t size) 
</span><span class="lines">@@ -295,12 +286,7 @@
</span><span class="cx"> {
</span><span class="cx">     return 1;
</span><span class="cx"> }
</span><del>-    
-size_t fastMallocGoodSize(size_t size)
-{
-    return size;
-}
-    
</del><ins>+
</ins><span class="cx"> void* fastAlignedMalloc(size_t alignment, size_t size) 
</span><span class="cx"> {
</span><span class="cx">     return bmalloc::api::memalign(alignment, size);
</span><span class="lines">@@ -2767,13 +2753,6 @@
</span><span class="cx"> 
</span><span class="cx"> #define pageheap getPageHeap()
</span><span class="cx"> 
</span><del>-size_t fastMallocGoodSize(size_t bytes)
-{
-    if (!phinited)
-        TCMalloc_ThreadCache::InitModule();
-    return AllocationSize(bytes);
-}
-
</del><span class="cx"> #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
</span><span class="cx"> 
</span><span class="cx"> #if HAVE(DISPATCH_H) || OS(WINDOWS)
</span></span></pre></div>
<a id="trunkSourceWTFwtfFastMalloch"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/FastMalloc.h (179742 => 179743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/FastMalloc.h        2015-02-06 08:31:30 UTC (rev 179742)
+++ trunk/Source/WTF/wtf/FastMalloc.h        2015-02-06 10:03:56 UTC (rev 179743)
</span><span class="lines">@@ -35,7 +35,6 @@
</span><span class="cx">     WTF_EXPORT_PRIVATE void* fastRealloc(void*, size_t);
</span><span class="cx">     WTF_EXPORT_PRIVATE char* fastStrDup(const char*);
</span><span class="cx">     WTF_EXPORT_PRIVATE size_t fastMallocSize(const void*);
</span><del>-    WTF_EXPORT_PRIVATE size_t fastMallocGoodSize(size_t);
</del><span class="cx"> 
</span><span class="cx">     // Allocations from fastAlignedMalloc() must be freed using fastAlignedFree().
</span><span class="cx">     WTF_EXPORT_PRIVATE void* fastAlignedMalloc(size_t alignment, size_t);
</span><span class="lines">@@ -99,7 +98,6 @@
</span><span class="cx"> using WTF::fastCalloc;
</span><span class="cx"> using WTF::fastFree;
</span><span class="cx"> using WTF::fastMalloc;
</span><del>-using WTF::fastMallocGoodSize;
</del><span class="cx"> using WTF::fastMallocSize;
</span><span class="cx"> using WTF::fastRealloc;
</span><span class="cx"> using WTF::fastStrDup;
</span></span></pre></div>
<a id="trunkSourceWTFwtfVectorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Vector.h (179742 => 179743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Vector.h        2015-02-06 08:31:30 UTC (rev 179742)
+++ trunk/Source/WTF/wtf/Vector.h        2015-02-06 10:03:56 UTC (rev 179743)
</span><span class="lines">@@ -264,9 +264,8 @@
</span><span class="cx">         ASSERT(newCapacity);
</span><span class="cx">         if (newCapacity &gt; std::numeric_limits&lt;unsigned&gt;::max() / sizeof(T))
</span><span class="cx">             CRASH();
</span><del>-        size_t sizeToAllocate = fastMallocGoodSize(newCapacity * sizeof(T));
-        m_capacity = sizeToAllocate / sizeof(T);
-        m_buffer = static_cast&lt;T*&gt;(fastMalloc(sizeToAllocate));
</del><ins>+        m_capacity = newCapacity;
+        m_buffer = static_cast&lt;T*&gt;(fastMalloc(newCapacity * sizeof(T)));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     bool tryAllocateBuffer(size_t newCapacity)
</span><span class="lines">@@ -275,10 +274,9 @@
</span><span class="cx">         if (newCapacity &gt; std::numeric_limits&lt;unsigned&gt;::max() / sizeof(T))
</span><span class="cx">             return false;
</span><span class="cx"> 
</span><del>-        size_t sizeToAllocate = fastMallocGoodSize(newCapacity * sizeof(T));
</del><span class="cx">         T* newBuffer;
</span><del>-        if (tryFastMalloc(sizeToAllocate).getValue(newBuffer)) {
-            m_capacity = sizeToAllocate / sizeof(T);
</del><ins>+        if (tryFastMalloc(newCapacity * sizeof(T)).getValue(newBuffer)) {
+            m_capacity = newCapacity;
</ins><span class="cx">             m_buffer = newBuffer;
</span><span class="cx">             return true;
</span><span class="cx">         }
</span><span class="lines">@@ -295,9 +293,8 @@
</span><span class="cx">         ASSERT(shouldReallocateBuffer(newCapacity));
</span><span class="cx">         if (newCapacity &gt; std::numeric_limits&lt;size_t&gt;::max() / sizeof(T))
</span><span class="cx">             CRASH();
</span><del>-        size_t sizeToAllocate = fastMallocGoodSize(newCapacity * sizeof(T));
-        m_capacity = sizeToAllocate / sizeof(T);
-        m_buffer = static_cast&lt;T*&gt;(fastRealloc(m_buffer, sizeToAllocate));
</del><ins>+        m_capacity = newCapacity;
+        m_buffer = static_cast&lt;T*&gt;(fastRealloc(m_buffer, newCapacity * sizeof(T)));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     void deallocateBuffer(T* bufferToDeallocate)
</span></span></pre>
</div>
</div>

</body>
</html>