<!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>[199442] releases/WebKitGTK/webkit-2.12/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/199442">199442</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-04-13 02:19:06 -0700 (Wed, 13 Apr 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/198606">r198606</a> - bmalloc: Added an Object helper class
https://bugs.webkit.org/show_bug.cgi?id=155818
Reviewed by Gavin Barraclough.
Object is an abstraction that breaks out a void* into its component
metadata pointers.
This is slightly faster than recomputing them, and it enables a future
patch in which Object will tell us whether it is small or large.
* bmalloc.xcodeproj/project.pbxproj: Added to the project.
* bmalloc/Allocator.cpp:
(bmalloc::Allocator::reallocate): Use Object to compute size.
* bmalloc/Deallocator.cpp:
(bmalloc::Deallocator::processObjectLog):
* bmalloc/Heap.cpp:
(bmalloc::Heap::allocateSmallPage):
(bmalloc::Heap::deallocateSmallLine):
* bmalloc/Heap.h:
(bmalloc::Heap::derefSmallLine): Use Object to deallocate.
* bmalloc/Object.h: Added.
(bmalloc::Object::Object):
(bmalloc::Object::chunk):
(bmalloc::Object::line):
(bmalloc::Object::page): Helper class to break out a void* into its
component metadata pointers.
* bmalloc/SmallChunk.h:
(bmalloc::SmallChunk::SmallChunk): SmallPage::get doesn't exist anymore
so we use our new helper functions instead.
(bmalloc::SmallChunk::offset):
(bmalloc::SmallChunk::object):
(bmalloc::SmallChunk::page):
(bmalloc::SmallChunk::line):
(bmalloc::SmallLine::begin):
(bmalloc::SmallLine::end):
(bmalloc::SmallPage::begin): New helpers that operate on the data
stored in Object.
(bmalloc::SmallLine::get): Deleted.
(bmalloc::SmallPage::get): Deleted.
* bmalloc/SmallLine.h:
(bmalloc::SmallLine::refCount): Added a default ref value for convenience.
* bmalloc/SmallPage.h:
(bmalloc::SmallPage::SmallPage):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit212SourcebmallocChangeLog">releases/WebKitGTK/webkit-2.12/Source/bmalloc/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourcebmallocbmallocAllocatorcpp">releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Allocator.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourcebmallocbmallocDeallocatorcpp">releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Deallocator.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourcebmallocbmallocHeapcpp">releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Heap.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourcebmallocbmallocHeaph">releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Heap.h</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourcebmallocbmallocSmallChunkh">releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallChunk.h</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourcebmallocbmallocSmallLineh">releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallLine.h</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourcebmallocbmallocSmallPageh">releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallPage.h</a></li>
<li><a href="#releasesWebKitGTKwebkit212Sourcebmallocbmallocxcodeprojprojectpbxproj">releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit212SourcebmallocbmallocObjecth">releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Object.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit212SourcebmallocChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/bmalloc/ChangeLog (199441 => 199442)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/ChangeLog        2016-04-13 09:17:48 UTC (rev 199441)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/ChangeLog        2016-04-13 09:19:06 UTC (rev 199442)
</span><span class="lines">@@ -1,5 +1,60 @@
</span><span class="cx"> 2016-03-23 Geoffrey Garen <ggaren@apple.com>
</span><span class="cx">
</span><ins>+ bmalloc: Added an Object helper class
+ https://bugs.webkit.org/show_bug.cgi?id=155818
+
+ Reviewed by Gavin Barraclough.
+
+ Object is an abstraction that breaks out a void* into its component
+ metadata pointers.
+
+ This is slightly faster than recomputing them, and it enables a future
+ patch in which Object will tell us whether it is small or large.
+
+ * bmalloc.xcodeproj/project.pbxproj: Added to the project.
+
+ * bmalloc/Allocator.cpp:
+ (bmalloc::Allocator::reallocate): Use Object to compute size.
+
+ * bmalloc/Deallocator.cpp:
+ (bmalloc::Deallocator::processObjectLog):
+ * bmalloc/Heap.cpp:
+ (bmalloc::Heap::allocateSmallPage):
+ (bmalloc::Heap::deallocateSmallLine):
+ * bmalloc/Heap.h:
+ (bmalloc::Heap::derefSmallLine): Use Object to deallocate.
+
+ * bmalloc/Object.h: Added.
+ (bmalloc::Object::Object):
+ (bmalloc::Object::chunk):
+ (bmalloc::Object::line):
+ (bmalloc::Object::page): Helper class to break out a void* into its
+ component metadata pointers.
+
+ * bmalloc/SmallChunk.h:
+ (bmalloc::SmallChunk::SmallChunk): SmallPage::get doesn't exist anymore
+ so we use our new helper functions instead.
+
+ (bmalloc::SmallChunk::offset):
+ (bmalloc::SmallChunk::object):
+ (bmalloc::SmallChunk::page):
+ (bmalloc::SmallChunk::line):
+ (bmalloc::SmallLine::begin):
+ (bmalloc::SmallLine::end):
+ (bmalloc::SmallPage::begin): New helpers that operate on the data
+ stored in Object.
+
+ (bmalloc::SmallLine::get): Deleted.
+ (bmalloc::SmallPage::get): Deleted.
+
+ * bmalloc/SmallLine.h:
+ (bmalloc::SmallLine::refCount): Added a default ref value for convenience.
+
+ * bmalloc/SmallPage.h:
+ (bmalloc::SmallPage::SmallPage):
+
+2016-03-23 Geoffrey Garen <ggaren@apple.com>
+
</ins><span class="cx"> bmalloc: process the object log before asking for new memory
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=155801
</span><span class="cx">
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourcebmallocbmallocAllocatorcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Allocator.cpp (199441 => 199442)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Allocator.cpp        2016-04-13 09:17:48 UTC (rev 199441)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Allocator.cpp        2016-04-13 09:19:06 UTC (rev 199442)
</span><span class="lines">@@ -115,8 +115,8 @@
</span><span class="cx"> size_t oldSize = 0;
</span><span class="cx"> switch (objectType(object)) {
</span><span class="cx"> case Small: {
</span><del>- SmallPage* page = SmallPage::get(SmallLine::get(object));
- oldSize = objectSize(page->sizeClass());
</del><ins>+ size_t sizeClass = Object(object).page()->sizeClass();
+ oldSize = objectSize(sizeClass);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case Large: {
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourcebmallocbmallocDeallocatorcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Deallocator.cpp (199441 => 199442)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Deallocator.cpp        2016-04-13 09:17:48 UTC (rev 199441)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Deallocator.cpp        2016-04-13 09:19:06 UTC (rev 199442)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include "Deallocator.h"
</span><span class="cx"> #include "Heap.h"
</span><span class="cx"> #include "Inline.h"
</span><ins>+#include "Object.h"
</ins><span class="cx"> #include "PerProcess.h"
</span><span class="cx"> #include "SmallChunk.h"
</span><span class="cx"> #include <algorithm>
</span><span class="lines">@@ -75,11 +76,9 @@
</span><span class="cx"> {
</span><span class="cx"> Heap* heap = PerProcess<Heap>::getFastCase();
</span><span class="cx">
</span><del>- for (auto* object : m_objectLog) {
- SmallLine* line = SmallLine::get(object);
- heap->derefSmallLine(lock, line);
- }
-
</del><ins>+ for (Object object : m_objectLog)
+ heap->derefSmallLine(lock, object);
+
</ins><span class="cx"> m_objectLog.clear();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourcebmallocbmallocHeapcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Heap.cpp (199441 => 199442)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Heap.cpp        2016-04-13 09:17:48 UTC (rev 199441)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Heap.cpp        2016-04-13 09:19:06 UTC (rev 199442)
</span><span class="lines">@@ -193,10 +193,10 @@
</span><span class="cx"> return page;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void Heap::deallocateSmallLine(std::lock_guard<StaticMutex>& lock, SmallLine* line)
</del><ins>+void Heap::deallocateSmallLine(std::lock_guard<StaticMutex>& lock, Object object)
</ins><span class="cx"> {
</span><del>- BASSERT(!line->refCount(lock));
- SmallPage* page = SmallPage::get(line);
</del><ins>+ BASSERT(!object.line()->refCount(lock));
+ SmallPage* page = object.page();
</ins><span class="cx"> page->deref(lock);
</span><span class="cx">
</span><span class="cx"> if (!page->hasFreeLines(lock)) {
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourcebmallocbmallocHeaph"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Heap.h (199441 => 199442)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Heap.h        2016-04-13 09:17:48 UTC (rev 199441)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Heap.h        2016-04-13 09:19:06 UTC (rev 199442)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include "LineMetadata.h"
</span><span class="cx"> #include "List.h"
</span><span class="cx"> #include "Mutex.h"
</span><ins>+#include "Object.h"
</ins><span class="cx"> #include "SegregatedFreeList.h"
</span><span class="cx"> #include "SmallChunk.h"
</span><span class="cx"> #include "SmallLine.h"
</span><span class="lines">@@ -54,7 +55,7 @@
</span><span class="cx"> Environment& environment() { return m_environment; }
</span><span class="cx">
</span><span class="cx"> void allocateSmallBumpRanges(std::lock_guard<StaticMutex>&, size_t sizeClass, BumpAllocator&, BumpRangeCache&);
</span><del>- void derefSmallLine(std::lock_guard<StaticMutex>&, SmallLine*);
</del><ins>+ void derefSmallLine(std::lock_guard<StaticMutex>&, Object);
</ins><span class="cx">
</span><span class="cx"> void* allocateLarge(std::lock_guard<StaticMutex>&, size_t);
</span><span class="cx"> void* allocateLarge(std::lock_guard<StaticMutex>&, size_t alignment, size_t, size_t unalignedSize);
</span><span class="lines">@@ -76,7 +77,7 @@
</span><span class="cx">
</span><span class="cx"> SmallPage* allocateSmallPage(std::lock_guard<StaticMutex>&, size_t sizeClass);
</span><span class="cx">
</span><del>- void deallocateSmallLine(std::lock_guard<StaticMutex>&, SmallLine*);
</del><ins>+ void deallocateSmallLine(std::lock_guard<StaticMutex>&, Object);
</ins><span class="cx"> void deallocateLarge(std::lock_guard<StaticMutex>&, const LargeObject&);
</span><span class="cx">
</span><span class="cx"> LargeObject& splitAndAllocate(LargeObject&, size_t);
</span><span class="lines">@@ -110,11 +111,11 @@
</span><span class="cx"> VMHeap m_vmHeap;
</span><span class="cx"> };
</span><span class="cx">
</span><del>-inline void Heap::derefSmallLine(std::lock_guard<StaticMutex>& lock, SmallLine* line)
</del><ins>+inline void Heap::derefSmallLine(std::lock_guard<StaticMutex>& lock, Object object)
</ins><span class="cx"> {
</span><del>- if (!line->deref(lock))
</del><ins>+ if (!object.line()->deref(lock))
</ins><span class="cx"> return;
</span><del>- deallocateSmallLine(lock, line);
</del><ins>+ deallocateSmallLine(lock, object);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace bmalloc
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourcebmallocbmallocObjecthfromrev199441releasesWebKitGTKwebkit212SourcebmallocbmallocSmallLineh"></a>
<div class="copfile"><h4>Copied: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Object.h (from rev 199441, releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallLine.h) (0 => 199442)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Object.h         (rev 0)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Object.h        2016-04-13 09:19:06 UTC (rev 199442)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef Object_h
+#define Object_h
+
+namespace bmalloc {
+
+class SmallChunk;
+class SmallLine;
+class SmallPage;
+
+class Object {
+public:
+ Object(void*);
+ Object(SmallChunk*, void*);
+
+ SmallChunk* chunk() { return m_chunk; }
+
+ SmallLine* line();
+ SmallPage* page();
+
+private:
+ SmallChunk* m_chunk;
+ size_t m_offset;
+};
+
+}; // namespace bmalloc
+
+#endif // Object_h
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourcebmallocbmallocSmallChunkh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallChunk.h (199441 => 199442)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallChunk.h        2016-04-13 09:17:48 UTC (rev 199441)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallChunk.h        2016-04-13 09:19:06 UTC (rev 199442)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #ifndef SmallChunk_h
</span><span class="cx"> #define SmallChunk_h
</span><span class="cx">
</span><ins>+#include "Object.h"
</ins><span class="cx"> #include "Sizes.h"
</span><span class="cx"> #include "SmallLine.h"
</span><span class="cx"> #include "SmallPage.h"
</span><span class="lines">@@ -38,8 +39,13 @@
</span><span class="cx"> SmallChunk(std::lock_guard<StaticMutex>&);
</span><span class="cx">
</span><span class="cx"> static SmallChunk* get(void*);
</span><ins>+ size_t offset(void*);
</ins><span class="cx">
</span><del>- SmallPage* begin() { return SmallPage::get(SmallLine::get(m_memory)); }
</del><ins>+ void* object(size_t offset);
+ SmallPage* page(size_t offset);
+ SmallLine* line(size_t offset);
+
+ SmallPage* begin() { return Object(m_memory).page(); }
</ins><span class="cx"> SmallPage* end() { return m_pages.end(); }
</span><span class="cx">
</span><span class="cx"> SmallLine* lines() { return m_lines.begin(); }
</span><span class="lines">@@ -60,15 +66,11 @@
</span><span class="cx"> inline SmallChunk::SmallChunk(std::lock_guard<StaticMutex>& lock)
</span><span class="cx"> {
</span><span class="cx"> // Track the memory used for metadata by allocating imaginary objects.
</span><del>- for (SmallLine* line = m_lines.begin(); line < SmallLine::get(m_memory); ++line) {
- line->ref(lock, 1);
-
- SmallPage* page = SmallPage::get(line);
- page->ref(lock);
</del><ins>+ for (char* it = reinterpret_cast<char*>(this); it < m_memory; it += smallLineSize) {
+ Object object(it);
+ object.line()->ref(lock);
+ object.page()->ref(lock);
</ins><span class="cx"> }
</span><del>-
- for (SmallPage* page = begin(); page != end(); ++page)
- page->setHasFreeLines(lock, true);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> inline SmallChunk* SmallChunk::get(void* object)
</span><span class="lines">@@ -77,14 +79,30 @@
</span><span class="cx"> return static_cast<SmallChunk*>(mask(object, smallChunkMask));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-inline SmallLine* SmallLine::get(void* object)
</del><ins>+inline size_t SmallChunk::offset(void* object)
</ins><span class="cx"> {
</span><del>- BASSERT(isSmall(object));
- SmallChunk* chunk = SmallChunk::get(object);
- size_t lineNumber = (reinterpret_cast<char*>(object) - reinterpret_cast<char*>(chunk)) / smallLineSize;
- return &chunk->lines()[lineNumber];
</del><ins>+ BASSERT(object >= this);
+ BASSERT(object < reinterpret_cast<char*>(this) + smallChunkSize);
+ return static_cast<char*>(object) - reinterpret_cast<char*>(this);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+inline void* SmallChunk::object(size_t offset)
+{
+ return reinterpret_cast<char*>(this) + offset;
+}
+
+inline SmallPage* SmallChunk::page(size_t offset)
+{
+ size_t pageNumber = offset / vmPageSize;
+ return &m_pages[pageNumber];
+}
+
+inline SmallLine* SmallChunk::line(size_t offset)
+{
+ size_t lineNumber = offset / smallLineSize;
+ return &m_lines[lineNumber];
+}
+
</ins><span class="cx"> inline char* SmallLine::begin()
</span><span class="cx"> {
</span><span class="cx"> SmallChunk* chunk = SmallChunk::get(this);
</span><span class="lines">@@ -98,14 +116,6 @@
</span><span class="cx"> return begin() + smallLineSize;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-inline SmallPage* SmallPage::get(SmallLine* line)
-{
- SmallChunk* chunk = SmallChunk::get(line);
- size_t lineNumber = line - chunk->lines();
- size_t pageNumber = lineNumber * smallLineSize / vmPageSize;
- return &chunk->pages()[pageNumber];
-}
-
</del><span class="cx"> inline SmallLine* SmallPage::begin()
</span><span class="cx"> {
</span><span class="cx"> SmallChunk* chunk = SmallChunk::get(this);
</span><span class="lines">@@ -119,6 +129,29 @@
</span><span class="cx"> return begin() + smallLineCount;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+inline Object::Object(void* object)
+ : m_chunk(SmallChunk::get(object))
+ , m_offset(m_chunk->offset(object))
+{
+}
+
+inline Object::Object(SmallChunk* chunk, void* object)
+ : m_chunk(chunk)
+ , m_offset(m_chunk->offset(object))
+{
+ BASSERT(chunk == SmallChunk::get(object));
+}
+
+inline SmallLine* Object::line()
+{
+ return m_chunk->line(m_offset);
+}
+
+inline SmallPage* Object::page()
+{
+ return m_chunk->page(m_offset);
+}
+
</ins><span class="cx"> }; // namespace bmalloc
</span><span class="cx">
</span><span class="cx"> #endif // Chunk
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourcebmallocbmallocSmallLineh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallLine.h (199441 => 199442)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallLine.h        2016-04-13 09:17:48 UTC (rev 199441)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallLine.h        2016-04-13 09:19:06 UTC (rev 199442)
</span><span class="lines">@@ -35,9 +35,7 @@
</span><span class="cx">
</span><span class="cx"> class SmallLine {
</span><span class="cx"> public:
</span><del>- static SmallLine* get(void*);
-
- void ref(std::lock_guard<StaticMutex>&, unsigned char);
</del><ins>+ void ref(std::lock_guard<StaticMutex>&, unsigned char = 1);
</ins><span class="cx"> bool deref(std::lock_guard<StaticMutex>&);
</span><span class="cx"> unsigned refCount(std::lock_guard<StaticMutex>&) { return m_refCount; }
</span><span class="cx">
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourcebmallocbmallocSmallPageh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallPage.h (199441 => 199442)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallPage.h        2016-04-13 09:17:48 UTC (rev 199441)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallPage.h        2016-04-13 09:19:06 UTC (rev 199442)
</span><span class="lines">@@ -36,8 +36,6 @@
</span><span class="cx">
</span><span class="cx"> class SmallPage : public ListNode<SmallPage> {
</span><span class="cx"> public:
</span><del>- static SmallPage* get(SmallLine*);
-
</del><span class="cx"> SmallPage()
</span><span class="cx"> : m_hasFreeLines(true)
</span><span class="cx"> {
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212Sourcebmallocbmallocxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj (199441 => 199442)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj        2016-04-13 09:17:48 UTC (rev 199441)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj        2016-04-13 09:19:06 UTC (rev 199442)
</span><span class="lines">@@ -22,6 +22,7 @@
</span><span class="cx">                 1440AFCD1A9527AF00837FAA /* Zone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1440AFCC1A9527AF00837FAA /* Zone.cpp */; };
</span><span class="cx">                 1448C30018F3754600502839 /* mbmalloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1448C2FF18F3754300502839 /* mbmalloc.cpp */; };
</span><span class="cx">                 1448C30118F3754C00502839 /* bmalloc.h in Headers */ = {isa = PBXBuildFile; fileRef = 1448C2FE18F3754300502839 /* bmalloc.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                144BE11F1CA346520099C8C0 /* Object.h in Headers */ = {isa = PBXBuildFile; fileRef = 144BE11E1CA346520099C8C0 /* Object.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 144C07F41C7B70260051BB6A /* XLargeMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 144C07F21C7B70260051BB6A /* XLargeMap.cpp */; };
</span><span class="cx">                 144C07F51C7B70260051BB6A /* XLargeMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 144C07F31C7B70260051BB6A /* XLargeMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 146041E71C7FF2EF00E9F94E /* SortedVector.h in Headers */ = {isa = PBXBuildFile; fileRef = 146041E61C7FF2EF00E9F94E /* SortedVector.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -103,6 +104,7 @@
</span><span class="cx">                 14446A0717A61FA400F9EA1D /* PerProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PerProcess.h; path = bmalloc/PerProcess.h; sourceTree = "<group>"; };
</span><span class="cx">                 1448C2FE18F3754300502839 /* bmalloc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = bmalloc.h; path = bmalloc/bmalloc.h; sourceTree = "<group>"; };
</span><span class="cx">                 1448C2FF18F3754300502839 /* mbmalloc.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mbmalloc.cpp; path = bmalloc/mbmalloc.cpp; sourceTree = "<group>"; };
</span><ins>+                144BE11E1CA346520099C8C0 /* Object.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Object.h; path = bmalloc/Object.h; sourceTree = "<group>"; };
</ins><span class="cx">                 144C07F21C7B70260051BB6A /* XLargeMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = XLargeMap.cpp; path = bmalloc/XLargeMap.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 144C07F31C7B70260051BB6A /* XLargeMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XLargeMap.h; path = bmalloc/XLargeMap.h; sourceTree = "<group>"; };
</span><span class="cx">                 144DCED617A649D90093B2F2 /* Mutex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Mutex.h; path = bmalloc/Mutex.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -264,6 +266,7 @@
</span><span class="cx">                                 14DA320E18875D9F007269E0 /* Heap.cpp */,
</span><span class="cx">                                 14DA320C18875B09007269E0 /* Heap.h */,
</span><span class="cx">                                 140FA00419CE4B6800FFD3C8 /* LineMetadata.h */,
</span><ins>+                                144BE11E1CA346520099C8C0 /* Object.h */,
</ins><span class="cx">                                 14105E8318E14374003A106E /* ObjectType.cpp */,
</span><span class="cx">                                 1485656018A43DBA00ED6942 /* ObjectType.h */,
</span><span class="cx">                                 145F6874179DF84100D65598 /* Sizes.h */,
</span><span class="lines">@@ -322,6 +325,7 @@
</span><span class="cx">                                 140FA00519CE4B6800FFD3C8 /* LineMetadata.h in Headers */,
</span><span class="cx">                                 14DD78CC18F48D7500950702 /* PerThread.h in Headers */,
</span><span class="cx">                                 14DD78CA18F48D7500950702 /* Mutex.h in Headers */,
</span><ins>+                                144BE11F1CA346520099C8C0 /* Object.h in Headers */,
</ins><span class="cx">                                 143CB81D19022BC900B16A45 /* StaticMutex.h in Headers */,
</span><span class="cx">                                 1448C30118F3754C00502839 /* bmalloc.h in Headers */,
</span><span class="cx">                                 14C6216F1A9A9A6200E72293 /* LargeObject.h in Headers */,
</span></span></pre>
</div>
</div>
</body>
</html>