<!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>[174109] trunk/Source/bmalloc</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/174109">174109</a></dd>
<dt>Author</dt> <dd>ggaren@apple.com</dd>
<dt>Date</dt> <dd>2014-09-30 11:37:45 -0700 (Tue, 30 Sep 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>bmalloc: cleaned up fast path vs slow path
https://bugs.webkit.org/show_bug.cgi?id=137081
Reviewed by Sam Weinig.
Might be a 1% speedup on MallocBench. Also cleans up the code a bit.
* bmalloc/Allocator.cpp:
(bmalloc::Allocator::Allocator): Merged the small and medium range
caches, just like the small and medium allocators. Ranges are abstract
objects that don't really care whether they hold small or medium objects,
so they don't need to be segregated.
(bmalloc::Allocator::scavenge): Ditto.
(bmalloc::Allocator::allocateBumpRangeSlowCase):
(bmalloc::Allocator::allocateBumpRange): Same thing here, except that
we do care a tiny bit, because we need to specify small vs medium when
allocating new ranges from the heap, to ensure that the heap allocates
from the right segment of VM.
(bmalloc::Allocator::allocateLarge):
(bmalloc::Allocator::allocateXLarge): NO_INLINE because this was clouding
up the fast path. Large allocation performance is dominated by allocation
logic and initialization, so inlining it doesn't help.
(bmalloc::Allocator::allocateSlowCase): Slow path got a bit cleaner since
it doesn't need to distinguish small vs medium objects.
(bmalloc::Allocator::allocateSmallBumpRange): Deleted.
(bmalloc::Allocator::allocateMediumBumpRange): Deleted.
* bmalloc/Allocator.h:
* bmalloc/BumpRange.h:
* bmalloc/Cache.cpp:
(bmalloc::Cache::allocateSlowCase): Deleted.
(bmalloc::Cache::deallocateSlowCase): Deleted.
* bmalloc/Cache.h:
(bmalloc::Cache::allocate):
(bmalloc::Cache::deallocate):
(bmalloc::Cache::allocateFastCase): Deleted.
(bmalloc::Cache::deallocateFastCase): Deleted. Removed the Cache slow
paths. The downside to this change is that the fast path branches to two
distinct failure cases instead of one. The upside is that the slow path
doesn't need to re-read the segment register, which is not as cheap as a
normal register, and it doesn't need to do an extra level of function
call. Seems to be worth it.
* bmalloc/Deallocator.h:
* bmalloc/Heap.cpp:
(bmalloc::Heap::refillSmallBumpRangeCache):
(bmalloc::Heap::refillMediumBumpRangeCache):
* bmalloc/Heap.h: Updated for interface changes.
* bmalloc/Sizes.h: The most ranges a cache will hold is the number of
small lines in a page / 2, since any other free lines will coalesce
with their neighbors.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourcebmallocChangeLog">trunk/Source/bmalloc/ChangeLog</a></li>
<li><a href="#trunkSourcebmallocbmallocAllocatorcpp">trunk/Source/bmalloc/bmalloc/Allocator.cpp</a></li>
<li><a href="#trunkSourcebmallocbmallocAllocatorh">trunk/Source/bmalloc/bmalloc/Allocator.h</a></li>
<li><a href="#trunkSourcebmallocbmallocBumpRangeh">trunk/Source/bmalloc/bmalloc/BumpRange.h</a></li>
<li><a href="#trunkSourcebmallocbmallocCachecpp">trunk/Source/bmalloc/bmalloc/Cache.cpp</a></li>
<li><a href="#trunkSourcebmallocbmallocCacheh">trunk/Source/bmalloc/bmalloc/Cache.h</a></li>
<li><a href="#trunkSourcebmallocbmallocDeallocatorh">trunk/Source/bmalloc/bmalloc/Deallocator.h</a></li>
<li><a href="#trunkSourcebmallocbmallocHeapcpp">trunk/Source/bmalloc/bmalloc/Heap.cpp</a></li>
<li><a href="#trunkSourcebmallocbmallocHeaph">trunk/Source/bmalloc/bmalloc/Heap.h</a></li>
<li><a href="#trunkSourcebmallocbmallocSizesh">trunk/Source/bmalloc/bmalloc/Sizes.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourcebmallocChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/ChangeLog (174108 => 174109)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/ChangeLog        2014-09-30 17:27:10 UTC (rev 174108)
+++ trunk/Source/bmalloc/ChangeLog        2014-09-30 18:37:45 UTC (rev 174109)
</span><span class="lines">@@ -1,3 +1,64 @@
</span><ins>+2014-09-24 Geoffrey Garen <ggaren@apple.com>
+
+ bmalloc: cleaned up fast path vs slow path
+ https://bugs.webkit.org/show_bug.cgi?id=137081
+
+ Reviewed by Sam Weinig.
+
+ Might be a 1% speedup on MallocBench. Also cleans up the code a bit.
+
+ * bmalloc/Allocator.cpp:
+ (bmalloc::Allocator::Allocator): Merged the small and medium range
+ caches, just like the small and medium allocators. Ranges are abstract
+ objects that don't really care whether they hold small or medium objects,
+ so they don't need to be segregated.
+
+ (bmalloc::Allocator::scavenge): Ditto.
+
+ (bmalloc::Allocator::allocateBumpRangeSlowCase):
+ (bmalloc::Allocator::allocateBumpRange): Same thing here, except that
+ we do care a tiny bit, because we need to specify small vs medium when
+ allocating new ranges from the heap, to ensure that the heap allocates
+ from the right segment of VM.
+
+ (bmalloc::Allocator::allocateLarge):
+ (bmalloc::Allocator::allocateXLarge): NO_INLINE because this was clouding
+ up the fast path. Large allocation performance is dominated by allocation
+ logic and initialization, so inlining it doesn't help.
+
+ (bmalloc::Allocator::allocateSlowCase): Slow path got a bit cleaner since
+ it doesn't need to distinguish small vs medium objects.
+
+ (bmalloc::Allocator::allocateSmallBumpRange): Deleted.
+ (bmalloc::Allocator::allocateMediumBumpRange): Deleted.
+
+ * bmalloc/Allocator.h:
+ * bmalloc/BumpRange.h:
+
+ * bmalloc/Cache.cpp:
+ (bmalloc::Cache::allocateSlowCase): Deleted.
+ (bmalloc::Cache::deallocateSlowCase): Deleted.
+ * bmalloc/Cache.h:
+ (bmalloc::Cache::allocate):
+ (bmalloc::Cache::deallocate):
+ (bmalloc::Cache::allocateFastCase): Deleted.
+ (bmalloc::Cache::deallocateFastCase): Deleted. Removed the Cache slow
+ paths. The downside to this change is that the fast path branches to two
+ distinct failure cases instead of one. The upside is that the slow path
+ doesn't need to re-read the segment register, which is not as cheap as a
+ normal register, and it doesn't need to do an extra level of function
+ call. Seems to be worth it.
+
+ * bmalloc/Deallocator.h:
+ * bmalloc/Heap.cpp:
+ (bmalloc::Heap::refillSmallBumpRangeCache):
+ (bmalloc::Heap::refillMediumBumpRangeCache):
+ * bmalloc/Heap.h: Updated for interface changes.
+
+ * bmalloc/Sizes.h: The most ranges a cache will hold is the number of
+ small lines in a page / 2, since any other free lines will coalesce
+ with their neighbors.
+
</ins><span class="cx"> 2014-09-23 Geoffrey Garen <ggaren@apple.com>
</span><span class="cx">
</span><span class="cx"> Rolled out r173346.
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocAllocatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/Allocator.cpp (174108 => 174109)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/Allocator.cpp        2014-09-30 17:27:10 UTC (rev 174108)
+++ trunk/Source/bmalloc/bmalloc/Allocator.cpp        2014-09-30 18:37:45 UTC (rev 174109)
</span><span class="lines">@@ -38,11 +38,8 @@
</span><span class="cx"> Allocator::Allocator(Deallocator& deallocator)
</span><span class="cx"> : m_deallocator(deallocator)
</span><span class="cx"> {
</span><del>- for (unsigned short size = alignment; size <= smallMax; size += alignment)
</del><ins>+ for (unsigned short size = alignment; size <= mediumMax; size += alignment)
</ins><span class="cx"> m_bumpAllocators[sizeClass(size)].init(size);
</span><del>-
- for (unsigned short size = smallMax + alignment; size <= mediumMax; size += alignment)
- m_bumpAllocators[sizeClass(size)].init(size);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> Allocator::~Allocator()
</span><span class="lines">@@ -52,9 +49,9 @@
</span><span class="cx">
</span><span class="cx"> void Allocator::scavenge()
</span><span class="cx"> {
</span><del>- for (unsigned short i = alignment; i <= smallMax; i += alignment) {
</del><ins>+ for (unsigned short i = alignment; i <= mediumMax; i += alignment) {
</ins><span class="cx"> BumpAllocator& allocator = m_bumpAllocators[sizeClass(i)];
</span><del>- SmallBumpRangeCache& bumpRangeCache = m_smallBumpRangeCaches[sizeClass(i)];
</del><ins>+ BumpRangeCache& bumpRangeCache = m_bumpRangeCaches[sizeClass(i)];
</ins><span class="cx">
</span><span class="cx"> while (allocator.canAllocate())
</span><span class="cx"> m_deallocator.deallocate(allocator.allocate());
</span><span class="lines">@@ -67,54 +64,37 @@
</span><span class="cx">
</span><span class="cx"> allocator.clear();
</span><span class="cx"> }
</span><del>-
- for (unsigned short i = smallMax + alignment; i <= mediumMax; i += alignment) {
- BumpAllocator& allocator = m_bumpAllocators[sizeClass(i)];
- MediumBumpRangeCache& bumpRangeCache = m_mediumBumpRangeCaches[sizeClass(i)];
-
- while (allocator.canAllocate())
- m_deallocator.deallocate(allocator.allocate());
-
- while (bumpRangeCache.size()) {
- allocator.refill(bumpRangeCache.pop());
- while (allocator.canAllocate())
- m_deallocator.deallocate(allocator.allocate());
- }
-
- allocator.clear();
- }
</del><span class="cx"> }
</span><span class="cx">
</span><del>-BumpRange Allocator::allocateSmallBumpRange(size_t sizeClass)
</del><ins>+NO_INLINE BumpRange Allocator::allocateBumpRangeSlowCase(size_t sizeClass)
</ins><span class="cx"> {
</span><del>- SmallBumpRangeCache& bumpRangeCache = m_smallBumpRangeCaches[sizeClass];
- if (!bumpRangeCache.size()) {
- std::lock_guard<StaticMutex> lock(PerProcess<Heap>::mutex());
</del><ins>+ BumpRangeCache& bumpRangeCache = m_bumpRangeCaches[sizeClass];
+
+ std::lock_guard<StaticMutex> lock(PerProcess<Heap>::mutex());
+ if (sizeClass <= bmalloc::sizeClass(smallMax))
</ins><span class="cx"> PerProcess<Heap>::getFastCase()->refillSmallBumpRangeCache(lock, sizeClass, bumpRangeCache);
</span><del>- }
</del><ins>+ else
+ PerProcess<Heap>::getFastCase()->refillMediumBumpRangeCache(lock, sizeClass, bumpRangeCache);
</ins><span class="cx">
</span><span class="cx"> return bumpRangeCache.pop();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-BumpRange Allocator::allocateMediumBumpRange(size_t sizeClass)
</del><ins>+INLINE BumpRange Allocator::allocateBumpRange(size_t sizeClass)
</ins><span class="cx"> {
</span><del>- MediumBumpRangeCache& bumpRangeCache = m_mediumBumpRangeCaches[sizeClass];
- if (!bumpRangeCache.size()) {
- std::lock_guard<StaticMutex> lock(PerProcess<Heap>::mutex());
- PerProcess<Heap>::getFastCase()->refillMediumBumpRangeCache(lock, sizeClass, bumpRangeCache);
- }
-
</del><ins>+ BumpRangeCache& bumpRangeCache = m_bumpRangeCaches[sizeClass];
+ if (!bumpRangeCache.size())
+ return allocateBumpRangeSlowCase(sizeClass);
</ins><span class="cx"> return bumpRangeCache.pop();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void* Allocator::allocateLarge(size_t size)
</del><ins>+NO_INLINE void* Allocator::allocateLarge(size_t size)
</ins><span class="cx"> {
</span><span class="cx"> size = roundUpToMultipleOf<largeAlignment>(size);
</span><span class="cx"> std::lock_guard<StaticMutex> lock(PerProcess<Heap>::mutex());
</span><span class="cx"> return PerProcess<Heap>::getFastCase()->allocateLarge(lock, size);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void* Allocator::allocateXLarge(size_t size)
</del><ins>+NO_INLINE void* Allocator::allocateXLarge(size_t size)
</ins><span class="cx"> {
</span><span class="cx"> size = roundUpToMultipleOf<largeAlignment>(size);
</span><span class="cx"> std::lock_guard<StaticMutex> lock(PerProcess<Heap>::mutex());
</span><span class="lines">@@ -123,26 +103,13 @@
</span><span class="cx">
</span><span class="cx"> void* Allocator::allocateSlowCase(size_t size)
</span><span class="cx"> {
</span><del>-IF_DEBUG(
- void* dummy;
- BASSERT(!allocateFastCase(size, dummy));
-)
-
</del><span class="cx"> if (size <= mediumMax) {
</span><span class="cx"> size_t sizeClass = bmalloc::sizeClass(size);
</span><span class="cx"> BumpAllocator& allocator = m_bumpAllocators[sizeClass];
</span><del>-
- if (allocator.size() <= smallMax) {
- allocator.refill(allocateSmallBumpRange(sizeClass));
- return allocator.allocate();
- }
-
- if (allocator.size() <= mediumMax) {
- allocator.refill(allocateMediumBumpRange(sizeClass));
- return allocator.allocate();
- }
</del><ins>+ allocator.refill(allocateBumpRange(sizeClass));
+ return allocator.allocate();
</ins><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> if (size <= largeMax)
</span><span class="cx"> return allocateLarge(size);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocAllocatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/Allocator.h (174108 => 174109)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/Allocator.h        2014-09-30 17:27:10 UTC (rev 174108)
+++ trunk/Source/bmalloc/bmalloc/Allocator.h        2014-09-30 18:37:45 UTC (rev 174109)
</span><span class="lines">@@ -45,27 +45,23 @@
</span><span class="cx"> ~Allocator();
</span><span class="cx">
</span><span class="cx"> void* allocate(size_t);
</span><del>- bool allocateFastCase(size_t, void*&);
- void* allocateSlowCase(size_t);
-
</del><span class="cx"> void scavenge();
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- void* allocateFastCase(BumpAllocator&);
-
</del><ins>+ bool allocateFastCase(size_t, void*&);
+ void* allocateSlowCase(size_t);
+
</ins><span class="cx"> void* allocateMedium(size_t);
</span><span class="cx"> void* allocateLarge(size_t);
</span><span class="cx"> void* allocateXLarge(size_t);
</span><span class="cx">
</span><del>- BumpRange allocateSmallBumpRange(size_t sizeClass);
- BumpRange allocateMediumBumpRange(size_t sizeClass);
</del><ins>+ BumpRange allocateBumpRange(size_t sizeClass);
+ BumpRange allocateBumpRangeSlowCase(size_t sizeClass);
</ins><span class="cx">
</span><span class="cx"> Deallocator& m_deallocator;
</span><span class="cx">
</span><span class="cx"> std::array<BumpAllocator, mediumMax / alignment> m_bumpAllocators;
</span><del>-
- std::array<SmallBumpRangeCache, smallMax / alignment> m_smallBumpRangeCaches;
- std::array<MediumBumpRangeCache, mediumMax / alignment> m_mediumBumpRangeCaches;
</del><ins>+ std::array<BumpRangeCache, mediumMax / alignment> m_bumpRangeCaches;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> inline bool Allocator::allocateFastCase(size_t size, void*& object)
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocBumpRangeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/BumpRange.h (174108 => 174109)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/BumpRange.h        2014-09-30 17:27:10 UTC (rev 174108)
+++ trunk/Source/bmalloc/bmalloc/BumpRange.h        2014-09-30 18:37:45 UTC (rev 174109)
</span><span class="lines">@@ -37,8 +37,7 @@
</span><span class="cx"> unsigned short objectCount;
</span><span class="cx"> };
</span><span class="cx">
</span><del>-typedef FixedVector<BumpRange, smallRangeCacheCapacity> SmallBumpRangeCache;
-typedef FixedVector<BumpRange, mediumRangeCacheCapacity> MediumBumpRangeCache;
</del><ins>+typedef FixedVector<BumpRange, bumpRangeCacheCapacity> BumpRangeCache;
</ins><span class="cx">
</span><span class="cx"> } // namespace bmalloc
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/Cache.cpp (174108 => 174109)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/Cache.cpp        2014-09-30 17:27:10 UTC (rev 174108)
+++ trunk/Source/bmalloc/bmalloc/Cache.cpp        2014-09-30 18:37:45 UTC (rev 174109)
</span><span class="lines">@@ -54,27 +54,11 @@
</span><span class="cx"> m_deallocator.scavenge();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-NO_INLINE void* Cache::allocateSlowCase(size_t size)
-{
- Cache* cache = PerThread<Cache>::getFastCase();
- if (!cache)
- return allocateSlowCaseNullCache(size);
- return cache->allocator().allocateSlowCase(size);
-}
-
</del><span class="cx"> NO_INLINE void* Cache::allocateSlowCaseNullCache(size_t size)
</span><span class="cx"> {
</span><span class="cx"> return PerThread<Cache>::getSlowCase()->allocator().allocate(size);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-NO_INLINE void Cache::deallocateSlowCase(void* object)
-{
- Cache* cache = PerThread<Cache>::getFastCase();
- if (!cache)
- return deallocateSlowCaseNullCache(object);
- cache->deallocator().deallocateSlowCase(object);
-}
-
</del><span class="cx"> NO_INLINE void Cache::deallocateSlowCaseNullCache(void* object)
</span><span class="cx"> {
</span><span class="cx"> PerThread<Cache>::getSlowCase()->deallocator().deallocate(object);
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/Cache.h (174108 => 174109)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/Cache.h        2014-09-30 17:27:10 UTC (rev 174108)
+++ trunk/Source/bmalloc/bmalloc/Cache.h        2014-09-30 18:37:45 UTC (rev 174109)
</span><span class="lines">@@ -50,48 +50,29 @@
</span><span class="cx"> void scavenge();
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- static bool allocateFastCase(size_t, void*&);
- static void* allocateSlowCase(size_t);
</del><span class="cx"> static void* allocateSlowCaseNullCache(size_t);
</span><del>-
- static bool deallocateFastCase(void*);
- static void deallocateSlowCase(void*);
</del><span class="cx"> static void deallocateSlowCaseNullCache(void*);
</span><span class="cx">
</span><span class="cx"> Deallocator m_deallocator;
</span><span class="cx"> Allocator m_allocator;
</span><span class="cx"> };
</span><span class="cx">
</span><del>-inline bool Cache::allocateFastCase(size_t size, void*& object)
</del><ins>+inline void* Cache::allocate(size_t size)
</ins><span class="cx"> {
</span><span class="cx"> Cache* cache = PerThread<Cache>::getFastCase();
</span><span class="cx"> if (!cache)
</span><del>- return false;
- return cache->allocator().allocateFastCase(size, object);
</del><ins>+ return allocateSlowCaseNullCache(size);
+ return cache->allocator().allocate(size);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-inline bool Cache::deallocateFastCase(void* object)
</del><ins>+inline void Cache::deallocate(void* object)
</ins><span class="cx"> {
</span><span class="cx"> Cache* cache = PerThread<Cache>::getFastCase();
</span><span class="cx"> if (!cache)
</span><del>- return false;
- return cache->deallocator().deallocateFastCase(object);
</del><ins>+ return deallocateSlowCaseNullCache(object);
+ return cache->deallocator().deallocate(object);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-inline void* Cache::allocate(size_t size)
-{
- void* object;
- if (!allocateFastCase(size, object))
- return allocateSlowCase(size);
- return object;
-}
-
-inline void Cache::deallocate(void* object)
-{
- if (!deallocateFastCase(object))
- deallocateSlowCase(object);
-}
-
</del><span class="cx"> } // namespace bmalloc
</span><span class="cx">
</span><span class="cx"> #endif // Cache_h
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocDeallocatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/Deallocator.h (174108 => 174109)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/Deallocator.h        2014-09-30 17:27:10 UTC (rev 174108)
+++ trunk/Source/bmalloc/bmalloc/Deallocator.h        2014-09-30 18:37:45 UTC (rev 174109)
</span><span class="lines">@@ -41,12 +41,12 @@
</span><span class="cx"> ~Deallocator();
</span><span class="cx">
</span><span class="cx"> void deallocate(void*);
</span><ins>+ void scavenge();
+
+private:
</ins><span class="cx"> bool deallocateFastCase(void*);
</span><span class="cx"> void deallocateSlowCase(void*);
</span><span class="cx">
</span><del>- void scavenge();
-
-private:
</del><span class="cx"> void deallocateLarge(void*);
</span><span class="cx"> void deallocateXLarge(void*);
</span><span class="cx"> void processObjectLog();
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocHeapcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/Heap.cpp (174108 => 174109)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/Heap.cpp        2014-09-30 17:27:10 UTC (rev 174108)
+++ trunk/Source/bmalloc/bmalloc/Heap.cpp        2014-09-30 18:37:45 UTC (rev 174109)
</span><span class="lines">@@ -152,7 +152,7 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void Heap::refillSmallBumpRangeCache(std::lock_guard<StaticMutex>& lock, size_t sizeClass, SmallBumpRangeCache& rangeCache)
</del><ins>+void Heap::refillSmallBumpRangeCache(std::lock_guard<StaticMutex>& lock, size_t sizeClass, BumpRangeCache& rangeCache)
</ins><span class="cx"> {
</span><span class="cx"> BASSERT(!rangeCache.size());
</span><span class="cx"> SmallPage* page = allocateSmallPage(lock, sizeClass);
</span><span class="lines">@@ -189,7 +189,7 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void Heap::refillMediumBumpRangeCache(std::lock_guard<StaticMutex>& lock, size_t sizeClass, MediumBumpRangeCache& rangeCache)
</del><ins>+void Heap::refillMediumBumpRangeCache(std::lock_guard<StaticMutex>& lock, size_t sizeClass, BumpRangeCache& rangeCache)
</ins><span class="cx"> {
</span><span class="cx"> MediumPage* page = allocateMediumPage(lock, sizeClass);
</span><span class="cx"> BASSERT(!rangeCache.size());
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocHeaph"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/Heap.h (174108 => 174109)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/Heap.h        2014-09-30 17:27:10 UTC (rev 174108)
+++ trunk/Source/bmalloc/bmalloc/Heap.h        2014-09-30 18:37:45 UTC (rev 174109)
</span><span class="lines">@@ -50,10 +50,10 @@
</span><span class="cx"> public:
</span><span class="cx"> Heap(std::lock_guard<StaticMutex>&);
</span><span class="cx">
</span><del>- void refillSmallBumpRangeCache(std::lock_guard<StaticMutex>&, size_t sizeClass, SmallBumpRangeCache&);
</del><ins>+ void refillSmallBumpRangeCache(std::lock_guard<StaticMutex>&, size_t sizeClass, BumpRangeCache&);
</ins><span class="cx"> void derefSmallLine(std::lock_guard<StaticMutex>&, SmallLine*);
</span><span class="cx">
</span><del>- void refillMediumBumpRangeCache(std::lock_guard<StaticMutex>&, size_t sizeClass, MediumBumpRangeCache&);
</del><ins>+ void refillMediumBumpRangeCache(std::lock_guard<StaticMutex>&, size_t sizeClass, BumpRangeCache&);
</ins><span class="cx"> void derefMediumLine(std::lock_guard<StaticMutex>&, MediumLine*);
</span><span class="cx">
</span><span class="cx"> void* allocateLarge(std::lock_guard<StaticMutex>&, size_t);
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocSizesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/Sizes.h (174108 => 174109)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/Sizes.h        2014-09-30 17:27:10 UTC (rev 174108)
+++ trunk/Source/bmalloc/bmalloc/Sizes.h        2014-09-30 18:37:45 UTC (rev 174109)
</span><span class="lines">@@ -91,9 +91,7 @@
</span><span class="cx"> static const uintptr_t smallOrMediumSmallTypeMask = smallType ^ mediumType; // Only valid if object is known to be small or medium.
</span><span class="cx">
</span><span class="cx"> static const size_t deallocatorLogCapacity = 256;
</span><del>-
- static const size_t smallRangeCacheCapacity = vmPageSize / smallLineSize;
- static const size_t mediumRangeCacheCapacity = vmPageSize / mediumLineSize;
</del><ins>+ static const size_t bumpRangeCacheCapacity = vmPageSize / smallLineSize / 2;
</ins><span class="cx">
</span><span class="cx"> static const std::chrono::milliseconds scavengeSleepDuration = std::chrono::milliseconds(512);
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>