<!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>[198679] 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/198679">198679</a></dd>
<dt>Author</dt> <dd>ggaren@apple.com</dd>
<dt>Date</dt> <dd>2016-03-25 11:32:11 -0700 (Fri, 25 Mar 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>bmalloc: Renamed LargeChunk => Chunk
https://bugs.webkit.org/show_bug.cgi?id=155894
Reviewed by Michael Saboff.
A Chunk can contain both small and large objects now.
* bmalloc.xcodeproj/project.pbxproj:
* bmalloc/Allocator.cpp:
(bmalloc::Allocator::allocate):
* bmalloc/BoundaryTag.h:
(bmalloc::BoundaryTag::isFree):
* bmalloc/Chunk.h: Copied from Source/bmalloc/bmalloc/LargeChunk.h.
(bmalloc::Chunk::pages):
(bmalloc::Chunk::begin):
(bmalloc::Chunk::end):
(bmalloc::Chunk::Chunk):
(bmalloc::Chunk::get):
(bmalloc::Chunk::beginTag):
(bmalloc::Chunk::endTag):
(bmalloc::Chunk::offset):
(bmalloc::Chunk::object):
(bmalloc::Chunk::page):
(bmalloc::Chunk::line):
(bmalloc::SmallLine::begin):
(bmalloc::SmallPage::begin):
(bmalloc::SmallPage::end):
(bmalloc::Object::Object):
(bmalloc::Object::begin):
(bmalloc::LargeChunk::pages): Deleted.
(bmalloc::LargeChunk::begin): Deleted.
(bmalloc::LargeChunk::end): Deleted.
(bmalloc::LargeChunk::LargeChunk): Deleted.
(bmalloc::LargeChunk::get): Deleted.
(bmalloc::LargeChunk::beginTag): Deleted.
(bmalloc::LargeChunk::endTag): Deleted.
(bmalloc::LargeChunk::offset): Deleted.
(bmalloc::LargeChunk::object): Deleted.
(bmalloc::LargeChunk::page): Deleted.
(bmalloc::LargeChunk::line): Deleted.
* bmalloc/Deallocator.cpp:
* bmalloc/FreeList.cpp:
* bmalloc/Heap.cpp:
(bmalloc::Heap::allocateLarge):
* bmalloc/LargeChunk.h: Removed.
* bmalloc/LargeObject.h:
(bmalloc::LargeObject::LargeObject):
(bmalloc::LargeObject::merge):
(bmalloc::LargeObject::split):
* bmalloc/Object.h:
(bmalloc::Object::chunk):
* bmalloc/ObjectType.cpp:
* bmalloc/Sizes.h:
* bmalloc/SmallAllocator.h: Removed.
* bmalloc/VMHeap.cpp:
(bmalloc::VMHeap::VMHeap):
(bmalloc::VMHeap::allocateChunk):
(bmalloc::VMHeap::allocateLargeChunk): Deleted.
* bmalloc/VMHeap.h:
(bmalloc::VMHeap::allocateLargeObject):
(bmalloc::VMHeap::deallocateLargeObject):
* bmalloc/Zone.cpp:
(bmalloc::enumerator):
* bmalloc/Zone.h:
(bmalloc::Zone::chunks):
(bmalloc::Zone::addChunk):
(bmalloc::Zone::largeChunks): Deleted.
(bmalloc::Zone::addLargeChunk): Deleted.</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="#trunkSourcebmallocbmallocBoundaryTagh">trunk/Source/bmalloc/bmalloc/BoundaryTag.h</a></li>
<li><a href="#trunkSourcebmallocbmallocDeallocatorcpp">trunk/Source/bmalloc/bmalloc/Deallocator.cpp</a></li>
<li><a href="#trunkSourcebmallocbmallocFreeListcpp">trunk/Source/bmalloc/bmalloc/FreeList.cpp</a></li>
<li><a href="#trunkSourcebmallocbmallocHeapcpp">trunk/Source/bmalloc/bmalloc/Heap.cpp</a></li>
<li><a href="#trunkSourcebmallocbmallocLargeObjecth">trunk/Source/bmalloc/bmalloc/LargeObject.h</a></li>
<li><a href="#trunkSourcebmallocbmallocObjecth">trunk/Source/bmalloc/bmalloc/Object.h</a></li>
<li><a href="#trunkSourcebmallocbmallocObjectTypecpp">trunk/Source/bmalloc/bmalloc/ObjectType.cpp</a></li>
<li><a href="#trunkSourcebmallocbmallocSizesh">trunk/Source/bmalloc/bmalloc/Sizes.h</a></li>
<li><a href="#trunkSourcebmallocbmallocVMHeapcpp">trunk/Source/bmalloc/bmalloc/VMHeap.cpp</a></li>
<li><a href="#trunkSourcebmallocbmallocVMHeaph">trunk/Source/bmalloc/bmalloc/VMHeap.h</a></li>
<li><a href="#trunkSourcebmallocbmallocZonecpp">trunk/Source/bmalloc/bmalloc/Zone.cpp</a></li>
<li><a href="#trunkSourcebmallocbmallocZoneh">trunk/Source/bmalloc/bmalloc/Zone.h</a></li>
<li><a href="#trunkSourcebmallocbmallocxcodeprojprojectpbxproj">trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourcebmallocbmallocChunkh">trunk/Source/bmalloc/bmalloc/Chunk.h</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourcebmallocbmallocLargeChunkh">trunk/Source/bmalloc/bmalloc/LargeChunk.h</a></li>
<li><a href="#trunkSourcebmallocbmallocSmallAllocatorh">trunk/Source/bmalloc/bmalloc/SmallAllocator.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourcebmallocChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/ChangeLog (198678 => 198679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/ChangeLog        2016-03-25 18:18:50 UTC (rev 198678)
+++ trunk/Source/bmalloc/ChangeLog        2016-03-25 18:32:11 UTC (rev 198679)
</span><span class="lines">@@ -1,3 +1,74 @@
</span><ins>+2016-03-25 Geoffrey Garen <ggaren@apple.com>
+
+ bmalloc: Renamed LargeChunk => Chunk
+ https://bugs.webkit.org/show_bug.cgi?id=155894
+
+ Reviewed by Michael Saboff.
+
+ A Chunk can contain both small and large objects now.
+
+ * bmalloc.xcodeproj/project.pbxproj:
+ * bmalloc/Allocator.cpp:
+ (bmalloc::Allocator::allocate):
+ * bmalloc/BoundaryTag.h:
+ (bmalloc::BoundaryTag::isFree):
+ * bmalloc/Chunk.h: Copied from Source/bmalloc/bmalloc/LargeChunk.h.
+ (bmalloc::Chunk::pages):
+ (bmalloc::Chunk::begin):
+ (bmalloc::Chunk::end):
+ (bmalloc::Chunk::Chunk):
+ (bmalloc::Chunk::get):
+ (bmalloc::Chunk::beginTag):
+ (bmalloc::Chunk::endTag):
+ (bmalloc::Chunk::offset):
+ (bmalloc::Chunk::object):
+ (bmalloc::Chunk::page):
+ (bmalloc::Chunk::line):
+ (bmalloc::SmallLine::begin):
+ (bmalloc::SmallPage::begin):
+ (bmalloc::SmallPage::end):
+ (bmalloc::Object::Object):
+ (bmalloc::Object::begin):
+ (bmalloc::LargeChunk::pages): Deleted.
+ (bmalloc::LargeChunk::begin): Deleted.
+ (bmalloc::LargeChunk::end): Deleted.
+ (bmalloc::LargeChunk::LargeChunk): Deleted.
+ (bmalloc::LargeChunk::get): Deleted.
+ (bmalloc::LargeChunk::beginTag): Deleted.
+ (bmalloc::LargeChunk::endTag): Deleted.
+ (bmalloc::LargeChunk::offset): Deleted.
+ (bmalloc::LargeChunk::object): Deleted.
+ (bmalloc::LargeChunk::page): Deleted.
+ (bmalloc::LargeChunk::line): Deleted.
+ * bmalloc/Deallocator.cpp:
+ * bmalloc/FreeList.cpp:
+ * bmalloc/Heap.cpp:
+ (bmalloc::Heap::allocateLarge):
+ * bmalloc/LargeChunk.h: Removed.
+ * bmalloc/LargeObject.h:
+ (bmalloc::LargeObject::LargeObject):
+ (bmalloc::LargeObject::merge):
+ (bmalloc::LargeObject::split):
+ * bmalloc/Object.h:
+ (bmalloc::Object::chunk):
+ * bmalloc/ObjectType.cpp:
+ * bmalloc/Sizes.h:
+ * bmalloc/SmallAllocator.h: Removed.
+ * bmalloc/VMHeap.cpp:
+ (bmalloc::VMHeap::VMHeap):
+ (bmalloc::VMHeap::allocateChunk):
+ (bmalloc::VMHeap::allocateLargeChunk): Deleted.
+ * bmalloc/VMHeap.h:
+ (bmalloc::VMHeap::allocateLargeObject):
+ (bmalloc::VMHeap::deallocateLargeObject):
+ * bmalloc/Zone.cpp:
+ (bmalloc::enumerator):
+ * bmalloc/Zone.h:
+ (bmalloc::Zone::chunks):
+ (bmalloc::Zone::addChunk):
+ (bmalloc::Zone::largeChunks): Deleted.
+ (bmalloc::Zone::addLargeChunk): Deleted.
+
</ins><span class="cx"> 2016-03-24 Geoffrey Garen <ggaren@apple.com>
</span><span class="cx">
</span><span class="cx"> bmalloc: small and large objects should share memory
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocAllocatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/Allocator.cpp (198678 => 198679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/Allocator.cpp        2016-03-25 18:18:50 UTC (rev 198678)
+++ trunk/Source/bmalloc/bmalloc/Allocator.cpp        2016-03-25 18:32:11 UTC (rev 198679)
</span><span class="lines">@@ -25,9 +25,9 @@
</span><span class="cx">
</span><span class="cx"> #include "Allocator.h"
</span><span class="cx"> #include "BAssert.h"
</span><ins>+#include "Chunk.h"
</ins><span class="cx"> #include "Deallocator.h"
</span><span class="cx"> #include "Heap.h"
</span><del>-#include "LargeChunk.h"
</del><span class="cx"> #include "LargeObject.h"
</span><span class="cx"> #include "PerProcess.h"
</span><span class="cx"> #include "Sizes.h"
</span><span class="lines">@@ -91,7 +91,7 @@
</span><span class="cx"> size = std::max(largeMin, roundUpToMultipleOf<largeAlignment>(size));
</span><span class="cx"> alignment = roundUpToMultipleOf<largeAlignment>(alignment);
</span><span class="cx"> size_t unalignedSize = largeMin + alignment - largeAlignment + size;
</span><del>- if (unalignedSize <= largeMax && alignment <= largeChunkSize / 2) {
</del><ins>+ if (unalignedSize <= largeMax && alignment <= chunkSize / 2) {
</ins><span class="cx"> std::lock_guard<StaticMutex> lock(PerProcess<Heap>::mutex());
</span><span class="cx"> m_deallocator.processObjectLog(lock);
</span><span class="cx"> return PerProcess<Heap>::getFastCase()->allocateLarge(lock, alignment, size, unalignedSize);
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocBoundaryTagh"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/BoundaryTag.h (198678 => 198679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/BoundaryTag.h        2016-03-25 18:18:50 UTC (rev 198678)
+++ trunk/Source/bmalloc/bmalloc/BoundaryTag.h        2016-03-25 18:32:11 UTC (rev 198679)
</span><span class="lines">@@ -36,12 +36,12 @@
</span><span class="cx">
</span><span class="cx"> class BeginTag;
</span><span class="cx"> class EndTag;
</span><del>-class LargeChunk;
</del><ins>+class Chunk;
</ins><span class="cx"> class Range;
</span><span class="cx">
</span><span class="cx"> class BoundaryTag {
</span><span class="cx"> public:
</span><del>- static Range init(LargeChunk*);
</del><ins>+ static Range init(Chunk*);
</ins><span class="cx"> static unsigned compactBegin(void*);
</span><span class="cx">
</span><span class="cx"> bool isFree() { return m_isFree; }
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocChunkhfromrev198675trunkSourcebmallocbmallocLargeChunkh"></a>
<div class="copfile"><h4>Copied: trunk/Source/bmalloc/bmalloc/Chunk.h (from rev 198675, trunk/Source/bmalloc/bmalloc/LargeChunk.h) (0 => 198679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/Chunk.h         (rev 0)
+++ trunk/Source/bmalloc/bmalloc/Chunk.h        2016-03-25 18:32:11 UTC (rev 198679)
</span><span class="lines">@@ -0,0 +1,239 @@
</span><ins>+/*
+ * Copyright (C) 2014 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 Chunk_h
+#define Chunk_h
+
+#include "BeginTag.h"
+#include "EndTag.h"
+#include "Object.h"
+#include "ObjectType.h"
+#include "Sizes.h"
+#include "SmallLine.h"
+#include "SmallPage.h"
+#include "VMAllocate.h"
+#include <array>
+
+namespace bmalloc {
+
+class Chunk {
+public:
+ static Chunk* get(void*);
+
+ static BeginTag* beginTag(void*);
+ static EndTag* endTag(void*, size_t);
+
+ Chunk(std::lock_guard<StaticMutex>&);
+
+ size_t offset(void*);
+
+ void* object(size_t offset);
+ SmallPage* page(size_t offset);
+ SmallLine* line(size_t offset);
+
+ SmallPage* pageBegin() { return Object(m_memory).page(); }
+ SmallPage* pageEnd() { return m_pages.end(); }
+
+ SmallLine* lines() { return m_lines.begin(); }
+ SmallPage* pages() { return m_pages.begin(); }
+
+ char* begin() { return m_memory; }
+ char* end() { return reinterpret_cast<char*>(this) + chunkSize; }
+
+private:
+ static const size_t boundaryTagCount = chunkSize / largeMin;
+ static_assert(boundaryTagCount > 2, "Chunk must have space for two sentinel boundary tags");
+
+ // Our metadata layout includes a left and right edge sentinel.
+ // Metadata takes up enough space to leave at least the first two
+ // boundary tag slots unused.
+ //
+ // So, boundary tag space looks like this:
+ //
+ // [OOXXXXX...]
+ //
+ // And BoundaryTag::get subtracts one, producing:
+ //
+ // [OXXXXX...O].
+ //
+ // We use the X's for boundary tags and the O's for edge sentinels.
+
+ std::array<SmallLine, chunkSize / smallLineSize> m_lines;
+ std::array<SmallPage, chunkSize / vmPageSize> m_pages;
+ std::array<BoundaryTag, boundaryTagCount> m_boundaryTags;
+ char m_memory[] __attribute__((aligned(2 * smallMax + 0)));
+};
+
+static_assert(sizeof(Chunk) + largeMax <= chunkSize, "largeMax is too big");
+static_assert(
+ sizeof(Chunk) % vmPageSize + 2 * smallMax <= vmPageSize,
+ "the first page of object memory in a small chunk must be able to allocate smallMax");
+
+inline Chunk::Chunk(std::lock_guard<StaticMutex>& lock)
+{
+ Range range(begin(), end() - begin());
+ BASSERT(range.size() <= largeObjectMax);
+
+ BeginTag* beginTag = Chunk::beginTag(range.begin());
+ beginTag->setRange(range);
+ beginTag->setFree(true);
+ beginTag->setVMState(VMState::Virtual);
+
+ EndTag* endTag = Chunk::endTag(range.begin(), range.size());
+ endTag->init(beginTag);
+
+ // Mark the left and right edges of our range as allocated. This naturally
+ // prevents merging logic from overflowing left (into metadata) or right
+ // (beyond our chunk), without requiring special-case checks.
+
+ EndTag* leftSentinel = beginTag->prev();
+ BASSERT(leftSentinel >= m_boundaryTags.begin());
+ BASSERT(leftSentinel < m_boundaryTags.end());
+ leftSentinel->initSentinel();
+
+ BeginTag* rightSentinel = endTag->next();
+ BASSERT(rightSentinel >= m_boundaryTags.begin());
+ BASSERT(rightSentinel < m_boundaryTags.end());
+ rightSentinel->initSentinel();
+
+ // Track the memory used for metadata by allocating imaginary objects.
+ for (char* it = reinterpret_cast<char*>(this); it < m_memory; it += smallLineSize) {
+ Object object(it);
+ object.line()->ref(lock);
+ object.page()->ref(lock);
+ }
+}
+
+inline Chunk* Chunk::get(void* object)
+{
+ return static_cast<Chunk*>(mask(object, chunkMask));
+}
+
+inline BeginTag* Chunk::beginTag(void* object)
+{
+ Chunk* chunk = get(object);
+ size_t boundaryTagNumber = (static_cast<char*>(object) - reinterpret_cast<char*>(chunk)) / largeMin - 1; // - 1 to offset from the right sentinel.
+ return static_cast<BeginTag*>(&chunk->m_boundaryTags[boundaryTagNumber]);
+}
+
+inline EndTag* Chunk::endTag(void* object, size_t size)
+{
+ Chunk* chunk = get(object);
+ char* end = static_cast<char*>(object) + size;
+
+ // We subtract largeMin before computing the end pointer's boundary tag. An
+ // object's size need not be an even multiple of largeMin. Subtracting
+ // largeMin rounds down to the last boundary tag prior to our neighbor.
+
+ size_t boundaryTagNumber = (end - largeMin - reinterpret_cast<char*>(chunk)) / largeMin - 1; // - 1 to offset from the right sentinel.
+ return static_cast<EndTag*>(&chunk->m_boundaryTags[boundaryTagNumber]);
+}
+
+inline size_t Chunk::offset(void* object)
+{
+ BASSERT(object >= this);
+ BASSERT(object < reinterpret_cast<char*>(this) + chunkSize);
+ return static_cast<char*>(object) - reinterpret_cast<char*>(this);
+}
+
+inline void* Chunk::object(size_t offset)
+{
+ return reinterpret_cast<char*>(this) + offset;
+}
+
+inline SmallPage* Chunk::page(size_t offset)
+{
+ size_t pageNumber = offset / vmPageSize;
+ return &m_pages[pageNumber];
+}
+
+inline SmallLine* Chunk::line(size_t offset)
+{
+ size_t lineNumber = offset / smallLineSize;
+ return &m_lines[lineNumber];
+}
+
+inline char* SmallLine::begin()
+{
+ Chunk* chunk = Chunk::get(this);
+ size_t lineNumber = this - chunk->lines();
+ size_t offset = lineNumber * smallLineSize;
+ return &reinterpret_cast<char*>(chunk)[offset];
+}
+
+inline char* SmallLine::end()
+{
+ return begin() + smallLineSize;
+}
+
+inline SmallLine* SmallPage::begin()
+{
+ Chunk* chunk = Chunk::get(this);
+ size_t pageNumber = this - chunk->pages();
+ size_t lineNumber = pageNumber * smallLineCount;
+ return &chunk->lines()[lineNumber];
+}
+
+inline SmallLine* SmallPage::end()
+{
+ return begin() + smallLineCount;
+}
+
+inline Object::Object(void* object)
+ : m_chunk(Chunk::get(object))
+ , m_offset(m_chunk->offset(object))
+{
+}
+
+inline Object::Object(Chunk* chunk, void* object)
+ : m_chunk(chunk)
+ , m_offset(m_chunk->offset(object))
+{
+ BASSERT(chunk == Chunk::get(object));
+}
+
+inline void* Object::begin()
+{
+ return m_chunk->object(m_offset);
+}
+
+inline void* Object::pageBegin()
+{
+ return m_chunk->object(roundDownToMultipleOf(vmPageSize, m_offset));
+}
+
+inline SmallLine* Object::line()
+{
+ return m_chunk->line(m_offset);
+}
+
+inline SmallPage* Object::page()
+{
+ return m_chunk->page(m_offset);
+}
+
+}; // namespace bmalloc
+
+#endif // Chunk
</ins></span></pre></div>
<a id="trunkSourcebmallocbmallocDeallocatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/Deallocator.cpp (198678 => 198679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/Deallocator.cpp        2016-03-25 18:18:50 UTC (rev 198678)
+++ trunk/Source/bmalloc/bmalloc/Deallocator.cpp        2016-03-25 18:32:11 UTC (rev 198679)
</span><span class="lines">@@ -24,7 +24,7 @@
</span><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> #include "BAssert.h"
</span><del>-#include "LargeChunk.h"
</del><ins>+#include "Chunk.h"
</ins><span class="cx"> #include "Deallocator.h"
</span><span class="cx"> #include "Heap.h"
</span><span class="cx"> #include "Inline.h"
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocFreeListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/FreeList.cpp (198678 => 198679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/FreeList.cpp        2016-03-25 18:18:50 UTC (rev 198678)
+++ trunk/Source/bmalloc/bmalloc/FreeList.cpp        2016-03-25 18:32:11 UTC (rev 198679)
</span><span class="lines">@@ -23,8 +23,8 @@
</span><span class="cx"> * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-#include "LargeChunk.h"
</del><span class="cx"> #include "FreeList.h"
</span><ins>+#include "Chunk.h"
</ins><span class="cx"> #include "Vector.h"
</span><span class="cx">
</span><span class="cx"> namespace bmalloc {
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocHeapcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/Heap.cpp (198678 => 198679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/Heap.cpp        2016-03-25 18:18:50 UTC (rev 198678)
+++ trunk/Source/bmalloc/bmalloc/Heap.cpp        2016-03-25 18:32:11 UTC (rev 198679)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx">
</span><span class="cx"> #include "Heap.h"
</span><span class="cx"> #include "BumpAllocator.h"
</span><del>-#include "LargeChunk.h"
</del><ins>+#include "Chunk.h"
</ins><span class="cx"> #include "LargeObject.h"
</span><span class="cx"> #include "PerProcess.h"
</span><span class="cx"> #include "SmallLine.h"
</span><span class="lines">@@ -334,7 +334,7 @@
</span><span class="cx"> BASSERT(unalignedSize <= largeMax);
</span><span class="cx"> BASSERT(unalignedSize >= largeMin);
</span><span class="cx"> BASSERT(unalignedSize == roundUpToMultipleOf<largeAlignment>(unalignedSize));
</span><del>- BASSERT(alignment <= largeChunkSize / 2);
</del><ins>+ BASSERT(alignment <= chunkSize / 2);
</ins><span class="cx"> BASSERT(alignment >= largeAlignment);
</span><span class="cx"> BASSERT(isPowerOfTwo(alignment));
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocLargeChunkh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/bmalloc/bmalloc/LargeChunk.h (198678 => 198679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/LargeChunk.h        2016-03-25 18:18:50 UTC (rev 198678)
+++ trunk/Source/bmalloc/bmalloc/LargeChunk.h        2016-03-25 18:32:11 UTC (rev 198679)
</span><span class="lines">@@ -1,239 +0,0 @@
</span><del>-/*
- * Copyright (C) 2014 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 LargeChunk_h
-#define LargeChunk_h
-
-#include "BeginTag.h"
-#include "EndTag.h"
-#include "Object.h"
-#include "ObjectType.h"
-#include "Sizes.h"
-#include "SmallLine.h"
-#include "SmallPage.h"
-#include "VMAllocate.h"
-#include <array>
-
-namespace bmalloc {
-
-class LargeChunk {
-public:
- static LargeChunk* get(void*);
-
- static BeginTag* beginTag(void*);
- static EndTag* endTag(void*, size_t);
-
- LargeChunk(std::lock_guard<StaticMutex>&);
-
- size_t offset(void*);
-
- void* object(size_t offset);
- SmallPage* page(size_t offset);
- SmallLine* line(size_t offset);
-
- SmallPage* pageBegin() { return Object(m_memory).page(); }
- SmallPage* pageEnd() { return m_pages.end(); }
-
- SmallLine* lines() { return m_lines.begin(); }
- SmallPage* pages() { return m_pages.begin(); }
-
- char* begin() { return m_memory; }
- char* end() { return reinterpret_cast<char*>(this) + largeChunkSize; }
-
-private:
- static const size_t boundaryTagCount = largeChunkSize / largeMin;
- static_assert(boundaryTagCount > 2, "LargeChunk must have space for two sentinel boundary tags");
-
- // Our metadata layout includes a left and right edge sentinel.
- // Metadata takes up enough space to leave at least the first two
- // boundary tag slots unused.
- //
- // So, boundary tag space looks like this:
- //
- // [OOXXXXX...]
- //
- // And BoundaryTag::get subtracts one, producing:
- //
- // [OXXXXX...O].
- //
- // We use the X's for boundary tags and the O's for edge sentinels.
-
- std::array<SmallLine, largeChunkSize / smallLineSize> m_lines;
- std::array<SmallPage, largeChunkSize / vmPageSize> m_pages;
- std::array<BoundaryTag, boundaryTagCount> m_boundaryTags;
- char m_memory[] __attribute__((aligned(2 * smallMax + 0)));
-};
-
-static_assert(sizeof(LargeChunk) + largeMax <= largeChunkSize, "largeMax is too big");
-static_assert(
- sizeof(LargeChunk) % vmPageSize + 2 * smallMax <= vmPageSize,
- "the first page of object memory in a small chunk must be able to allocate smallMax");
-
-inline LargeChunk::LargeChunk(std::lock_guard<StaticMutex>& lock)
-{
- Range range(begin(), end() - begin());
- BASSERT(range.size() <= largeObjectMax);
-
- BeginTag* beginTag = LargeChunk::beginTag(range.begin());
- beginTag->setRange(range);
- beginTag->setFree(true);
- beginTag->setVMState(VMState::Virtual);
-
- EndTag* endTag = LargeChunk::endTag(range.begin(), range.size());
- endTag->init(beginTag);
-
- // Mark the left and right edges of our range as allocated. This naturally
- // prevents merging logic from overflowing left (into metadata) or right
- // (beyond our chunk), without requiring special-case checks.
-
- EndTag* leftSentinel = beginTag->prev();
- BASSERT(leftSentinel >= m_boundaryTags.begin());
- BASSERT(leftSentinel < m_boundaryTags.end());
- leftSentinel->initSentinel();
-
- BeginTag* rightSentinel = endTag->next();
- BASSERT(rightSentinel >= m_boundaryTags.begin());
- BASSERT(rightSentinel < m_boundaryTags.end());
- rightSentinel->initSentinel();
-
- // Track the memory used for metadata by allocating imaginary objects.
- for (char* it = reinterpret_cast<char*>(this); it < m_memory; it += smallLineSize) {
- Object object(it);
- object.line()->ref(lock);
- object.page()->ref(lock);
- }
-}
-
-inline LargeChunk* LargeChunk::get(void* object)
-{
- return static_cast<LargeChunk*>(mask(object, largeChunkMask));
-}
-
-inline BeginTag* LargeChunk::beginTag(void* object)
-{
- LargeChunk* chunk = get(object);
- size_t boundaryTagNumber = (static_cast<char*>(object) - reinterpret_cast<char*>(chunk)) / largeMin - 1; // - 1 to offset from the right sentinel.
- return static_cast<BeginTag*>(&chunk->m_boundaryTags[boundaryTagNumber]);
-}
-
-inline EndTag* LargeChunk::endTag(void* object, size_t size)
-{
- LargeChunk* chunk = get(object);
- char* end = static_cast<char*>(object) + size;
-
- // We subtract largeMin before computing the end pointer's boundary tag. An
- // object's size need not be an even multiple of largeMin. Subtracting
- // largeMin rounds down to the last boundary tag prior to our neighbor.
-
- size_t boundaryTagNumber = (end - largeMin - reinterpret_cast<char*>(chunk)) / largeMin - 1; // - 1 to offset from the right sentinel.
- return static_cast<EndTag*>(&chunk->m_boundaryTags[boundaryTagNumber]);
-}
-
-inline size_t LargeChunk::offset(void* object)
-{
- BASSERT(object >= this);
- BASSERT(object < reinterpret_cast<char*>(this) + largeChunkSize);
- return static_cast<char*>(object) - reinterpret_cast<char*>(this);
-}
-
-inline void* LargeChunk::object(size_t offset)
-{
- return reinterpret_cast<char*>(this) + offset;
-}
-
-inline SmallPage* LargeChunk::page(size_t offset)
-{
- size_t pageNumber = offset / vmPageSize;
- return &m_pages[pageNumber];
-}
-
-inline SmallLine* LargeChunk::line(size_t offset)
-{
- size_t lineNumber = offset / smallLineSize;
- return &m_lines[lineNumber];
-}
-
-inline char* SmallLine::begin()
-{
- LargeChunk* chunk = LargeChunk::get(this);
- size_t lineNumber = this - chunk->lines();
- size_t offset = lineNumber * smallLineSize;
- return &reinterpret_cast<char*>(chunk)[offset];
-}
-
-inline char* SmallLine::end()
-{
- return begin() + smallLineSize;
-}
-
-inline SmallLine* SmallPage::begin()
-{
- LargeChunk* chunk = LargeChunk::get(this);
- size_t pageNumber = this - chunk->pages();
- size_t lineNumber = pageNumber * smallLineCount;
- return &chunk->lines()[lineNumber];
-}
-
-inline SmallLine* SmallPage::end()
-{
- return begin() + smallLineCount;
-}
-
-inline Object::Object(void* object)
- : m_chunk(LargeChunk::get(object))
- , m_offset(m_chunk->offset(object))
-{
-}
-
-inline Object::Object(LargeChunk* chunk, void* object)
- : m_chunk(chunk)
- , m_offset(m_chunk->offset(object))
-{
- BASSERT(chunk == LargeChunk::get(object));
-}
-
-inline void* Object::begin()
-{
- return m_chunk->object(m_offset);
-}
-
-inline void* Object::pageBegin()
-{
- return m_chunk->object(roundDownToMultipleOf(vmPageSize, m_offset));
-}
-
-inline SmallLine* Object::line()
-{
- return m_chunk->line(m_offset);
-}
-
-inline SmallPage* Object::page()
-{
- return m_chunk->page(m_offset);
-}
-
-}; // namespace bmalloc
-
-#endif // LargeChunk
</del></span></pre></div>
<a id="trunkSourcebmallocbmallocLargeObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/LargeObject.h (198678 => 198679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/LargeObject.h        2016-03-25 18:18:50 UTC (rev 198678)
+++ trunk/Source/bmalloc/bmalloc/LargeObject.h        2016-03-25 18:32:11 UTC (rev 198679)
</span><span class="lines">@@ -27,8 +27,8 @@
</span><span class="cx"> #define LargeObject_h
</span><span class="cx">
</span><span class="cx"> #include "BeginTag.h"
</span><ins>+#include "Chunk.h"
</ins><span class="cx"> #include "EndTag.h"
</span><del>-#include "LargeChunk.h"
</del><span class="cx"> #include "Range.h"
</span><span class="cx">
</span><span class="cx"> namespace bmalloc {
</span><span class="lines">@@ -85,16 +85,16 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> inline LargeObject::LargeObject(void* object)
</span><del>- : m_beginTag(LargeChunk::beginTag(object))
- , m_endTag(LargeChunk::endTag(object, m_beginTag->size()))
</del><ins>+ : m_beginTag(Chunk::beginTag(object))
+ , m_endTag(Chunk::endTag(object, m_beginTag->size()))
</ins><span class="cx"> , m_object(object)
</span><span class="cx"> {
</span><span class="cx"> validate();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> inline LargeObject::LargeObject(DoNotValidateTag, void* object)
</span><del>- : m_beginTag(LargeChunk::beginTag(object))
- , m_endTag(LargeChunk::endTag(object, m_beginTag->size()))
</del><ins>+ : m_beginTag(Chunk::beginTag(object))
+ , m_endTag(Chunk::endTag(object, m_beginTag->size()))
</ins><span class="cx"> , m_object(object)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -194,7 +194,7 @@
</span><span class="cx"> prev->clear();
</span><span class="cx"> beginTag->clear();
</span><span class="cx">
</span><del>- beginTag = LargeChunk::beginTag(range.begin());
</del><ins>+ beginTag = Chunk::beginTag(range.begin());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> BeginTag* next = endTag->next();
</span><span class="lines">@@ -206,7 +206,7 @@
</span><span class="cx"> endTag->clear();
</span><span class="cx"> next->clear();
</span><span class="cx">
</span><del>- endTag = LargeChunk::endTag(range.begin(), range.size());
</del><ins>+ endTag = Chunk::endTag(range.begin(), range.size());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> beginTag->setRange(range);
</span><span class="lines">@@ -225,9 +225,9 @@
</span><span class="cx"> BASSERT(leftover.size() >= largeMin);
</span><span class="cx">
</span><span class="cx"> BeginTag* splitBeginTag = m_beginTag;
</span><del>- EndTag* splitEndTag = LargeChunk::endTag(split.begin(), size);
</del><ins>+ EndTag* splitEndTag = Chunk::endTag(split.begin(), size);
</ins><span class="cx">
</span><del>- BeginTag* leftoverBeginTag = LargeChunk::beginTag(leftover.begin());
</del><ins>+ BeginTag* leftoverBeginTag = Chunk::beginTag(leftover.begin());
</ins><span class="cx"> EndTag* leftoverEndTag = m_endTag;
</span><span class="cx">
</span><span class="cx"> splitBeginTag->setRange(split);
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/Object.h (198678 => 198679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/Object.h        2016-03-25 18:18:50 UTC (rev 198678)
+++ trunk/Source/bmalloc/bmalloc/Object.h        2016-03-25 18:32:11 UTC (rev 198679)
</span><span class="lines">@@ -28,16 +28,16 @@
</span><span class="cx">
</span><span class="cx"> namespace bmalloc {
</span><span class="cx">
</span><del>-class LargeChunk;
</del><ins>+class Chunk;
</ins><span class="cx"> class SmallLine;
</span><span class="cx"> class SmallPage;
</span><span class="cx">
</span><span class="cx"> class Object {
</span><span class="cx"> public:
</span><span class="cx"> Object(void*);
</span><del>- Object(LargeChunk*, void*);
</del><ins>+ Object(Chunk*, void*);
</ins><span class="cx">
</span><del>- LargeChunk* chunk() { return m_chunk; }
</del><ins>+ Chunk* chunk() { return m_chunk; }
</ins><span class="cx"> void* begin();
</span><span class="cx"> void* pageBegin();
</span><span class="cx">
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx"> SmallPage* page();
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- LargeChunk* m_chunk;
</del><ins>+ Chunk* m_chunk;
</ins><span class="cx"> size_t m_offset;
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocObjectTypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/ObjectType.cpp (198678 => 198679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/ObjectType.cpp        2016-03-25 18:18:50 UTC (rev 198678)
+++ trunk/Source/bmalloc/bmalloc/ObjectType.cpp        2016-03-25 18:32:11 UTC (rev 198679)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx">
</span><span class="cx"> #include "ObjectType.h"
</span><span class="cx">
</span><del>-#include "LargeChunk.h"
</del><ins>+#include "Chunk.h"
</ins><span class="cx"> #include "Object.h"
</span><span class="cx">
</span><span class="cx"> namespace bmalloc {
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocSizesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/Sizes.h (198678 => 198679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/Sizes.h        2016-03-25 18:18:50 UTC (rev 198678)
+++ trunk/Source/bmalloc/bmalloc/Sizes.h        2016-03-25 18:32:11 UTC (rev 198679)
</span><span class="lines">@@ -58,15 +58,15 @@
</span><span class="cx"> static const size_t smallMax = 1 * kB;
</span><span class="cx"> static const size_t maskSizeClassMax = 512;
</span><span class="cx">
</span><del>- static const size_t largeChunkSize = 2 * MB;
- static const size_t largeChunkMask = ~(largeChunkSize - 1ul);
</del><ins>+ static const size_t chunkSize = 2 * MB;
+ static const size_t chunkMask = ~(chunkSize - 1ul);
</ins><span class="cx">
</span><span class="cx"> static const size_t largeAlignment = 64;
</span><span class="cx"> static const size_t largeMin = smallMax;
</span><del>- static const size_t largeObjectMax = largeChunkSize;
</del><ins>+ static const size_t largeObjectMax = chunkSize;
</ins><span class="cx"> static const size_t largeMax = largeObjectMax / 2;
</span><span class="cx">
</span><del>- static const size_t xLargeAlignment = largeChunkSize;
</del><ins>+ static const size_t xLargeAlignment = chunkSize;
</ins><span class="cx"> static const size_t xLargeMask = ~(xLargeAlignment - 1);
</span><span class="cx"> static const size_t xLargeMax = std::numeric_limits<size_t>::max() - xLargeAlignment; // Make sure that rounding up to xLargeAlignment does not overflow.
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocSmallAllocatorh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/bmalloc/bmalloc/SmallAllocator.h ( => )</h4>
<pre class="diff"><span>
<span class="info">Modified: trunk/Source/bmalloc/bmalloc/VMHeap.cpp
===================================================================
</span><del>--- trunk/Source/bmalloc/bmalloc/VMHeap.cpp        2016-03-25 18:18:50 UTC (rev 198678)
</del><ins>+++ trunk/Source/bmalloc/bmalloc/VMHeap.cpp        2016-03-25 18:32:11 UTC (rev 198679)
</ins><span class="lines">@@ -35,16 +35,16 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><del>-LargeObject VMHeap::allocateLargeChunk(std::lock_guard<StaticMutex>& lock)
</del><ins>+LargeObject VMHeap::allocateChunk(std::lock_guard<StaticMutex>& lock)
</ins><span class="cx"> {
</span><del>- LargeChunk* largeChunk =
- new (vmAllocate(largeChunkSize, largeChunkSize)) LargeChunk(lock);
</del><ins>+ Chunk* chunk =
+ new (vmAllocate(chunkSize, chunkSize)) Chunk(lock);
</ins><span class="cx">
</span><span class="cx"> #if BOS(DARWIN)
</span><del>- m_zone.addLargeChunk(largeChunk);
</del><ins>+ m_zone.addChunk(chunk);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- return LargeObject(largeChunk->begin());
</del><ins>+ return LargeObject(chunk->begin());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace bmalloc
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocVMHeaph"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/VMHeap.h (198678 => 198679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/VMHeap.h        2016-03-25 18:18:50 UTC (rev 198678)
+++ trunk/Source/bmalloc/bmalloc/VMHeap.h        2016-03-25 18:32:11 UTC (rev 198679)
</span><span class="lines">@@ -27,8 +27,8 @@
</span><span class="cx"> #define VMHeap_h
</span><span class="cx">
</span><span class="cx"> #include "AsyncTask.h"
</span><ins>+#include "Chunk.h"
</ins><span class="cx"> #include "FixedVector.h"
</span><del>-#include "LargeChunk.h"
</del><span class="cx"> #include "LargeObject.h"
</span><span class="cx"> #include "Range.h"
</span><span class="cx"> #include "SegregatedFreeList.h"
</span><span class="lines">@@ -54,7 +54,7 @@
</span><span class="cx"> void deallocateLargeObject(std::unique_lock<StaticMutex>&, LargeObject);
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- LargeObject allocateLargeChunk(std::lock_guard<StaticMutex>&);
</del><ins>+ LargeObject allocateChunk(std::lock_guard<StaticMutex>&);
</ins><span class="cx">
</span><span class="cx"> SegregatedFreeList m_largeObjects;
</span><span class="cx">
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx"> return largeObject;
</span><span class="cx">
</span><span class="cx"> BASSERT(size <= largeMax);
</span><del>- return allocateLargeChunk(lock);
</del><ins>+ return allocateChunk(lock);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> inline LargeObject VMHeap::allocateLargeObject(std::lock_guard<StaticMutex>& lock, size_t alignment, size_t size, size_t unalignedSize)
</span><span class="lines">@@ -78,7 +78,7 @@
</span><span class="cx"> return largeObject;
</span><span class="cx">
</span><span class="cx"> BASSERT(unalignedSize <= largeMax);
</span><del>- return allocateLargeChunk(lock);
</del><ins>+ return allocateChunk(lock);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> inline void VMHeap::deallocateLargeObject(std::unique_lock<StaticMutex>& lock, LargeObject largeObject)
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocZonecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/Zone.cpp (198678 => 198679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/Zone.cpp        2016-03-25 18:18:50 UTC (rev 198678)
+++ trunk/Source/bmalloc/bmalloc/Zone.cpp        2016-03-25 18:32:11 UTC (rev 198679)
</span><span class="lines">@@ -88,8 +88,8 @@
</span><span class="cx"> static kern_return_t enumerator(task_t task, void* context, unsigned type_mask, vm_address_t zone_address, memory_reader_t reader, vm_range_recorder_t recorder)
</span><span class="cx"> {
</span><span class="cx"> Zone remoteZone(task, reader, zone_address);
</span><del>- for (auto* largeChunk : remoteZone.largeChunks()) {
- vm_range_t range = { reinterpret_cast<vm_address_t>(largeChunk), largeChunkSize };
</del><ins>+ for (auto* chunk : remoteZone.chunks()) {
+ vm_range_t range = { reinterpret_cast<vm_address_t>(chunk), chunkSize };
</ins><span class="cx">
</span><span class="cx"> if ((type_mask & MALLOC_PTR_REGION_RANGE_TYPE))
</span><span class="cx"> (*recorder)(task, context, MALLOC_PTR_REGION_RANGE_TYPE, &range, 1);
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocZoneh"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/Zone.h (198678 => 198679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/Zone.h        2016-03-25 18:18:50 UTC (rev 198678)
+++ trunk/Source/bmalloc/bmalloc/Zone.h        2016-03-25 18:32:11 UTC (rev 198679)
</span><span class="lines">@@ -31,7 +31,7 @@
</span><span class="cx">
</span><span class="cx"> namespace bmalloc {
</span><span class="cx">
</span><del>-class LargeChunk;
</del><ins>+class Chunk;
</ins><span class="cx">
</span><span class="cx"> class Zone : public malloc_zone_t {
</span><span class="cx"> public:
</span><span class="lines">@@ -41,30 +41,30 @@
</span><span class="cx"> Zone();
</span><span class="cx"> Zone(task_t, memory_reader_t, vm_address_t);
</span><span class="cx">
</span><del>- void addLargeChunk(LargeChunk*);
- FixedVector<LargeChunk*, capacity>& largeChunks() { return m_largeChunks; }
</del><ins>+ void addChunk(Chunk*);
+ FixedVector<Chunk*, capacity>& chunks() { return m_chunks; }
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> // This vector has two purposes:
</span><del>- // (1) It stores the list of LargeChunks so that we can enumerate
- // each LargeChunk and request that it be scanned if reachable.
- // (2) It roots a pointer to each LargeChunk in a global non-malloc
- // VM region, making each LargeChunk appear reachable, and therefore
</del><ins>+ // (1) It stores the list of Chunks so that we can enumerate
+ // each Chunk and request that it be scanned if reachable.
+ // (2) It roots a pointer to each Chunk in a global non-malloc
+ // VM region, making each Chunk appear reachable, and therefore
</ins><span class="cx"> // ensuring that the leaks tool will scan it. (The leaks tool
</span><span class="cx"> // conservatively scans all writeable VM regions that are not malloc
</span><span class="cx"> // regions, and then scans malloc regions using the introspection API.)
</span><span class="cx"> // This prevents the leaks tool from reporting false positive leaks for
</span><span class="cx"> // objects pointed to from bmalloc memory -- though it also prevents the
</span><span class="cx"> // leaks tool from finding any leaks in bmalloc memory.
</span><del>- FixedVector<LargeChunk*, capacity> m_largeChunks;
</del><ins>+ FixedVector<Chunk*, capacity> m_chunks;
</ins><span class="cx"> };
</span><span class="cx">
</span><del>-inline void Zone::addLargeChunk(LargeChunk* largeChunk)
</del><ins>+inline void Zone::addChunk(Chunk* chunk)
</ins><span class="cx"> {
</span><del>- if (m_largeChunks.size() == m_largeChunks.capacity())
</del><ins>+ if (m_chunks.size() == m_chunks.capacity())
</ins><span class="cx"> return;
</span><span class="cx">
</span><del>- m_largeChunks.push(largeChunk);
</del><ins>+ m_chunks.push(chunk);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace bmalloc
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj (198678 => 198679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj        2016-03-25 18:18:50 UTC (rev 198678)
+++ trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj        2016-03-25 18:32:11 UTC (rev 198679)
</span><span class="lines">@@ -25,13 +25,13 @@
</span><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><ins>+                147DC6E31CA5B70B00724E8D /* Chunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 147DC6E21CA5B70B00724E8D /* Chunk.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 14895D911A3A319C0006235D /* Environment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14895D8F1A3A319C0006235D /* Environment.cpp */; };
</span><span class="cx">                 14895D921A3A319C0006235D /* Environment.h in Headers */ = {isa = PBXBuildFile; fileRef = 14895D901A3A319C0006235D /* Environment.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 14C6216F1A9A9A6200E72293 /* LargeObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 14C6216E1A9A9A6200E72293 /* LargeObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 14C919C918FCC59F0028DB43 /* BPlatform.h in Headers */ = {isa = PBXBuildFile; fileRef = 14C919C818FCC59F0028DB43 /* BPlatform.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 14CC394C18EA8858004AFE34 /* libbmalloc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14F271BE18EA3963008C152F /* libbmalloc.a */; };
</span><span class="cx">                 14D2CD9B1AA12CFB00770440 /* VMState.h in Headers */ = {isa = PBXBuildFile; fileRef = 14D2CD9A1AA12CFB00770440 /* VMState.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-                14DD788C18F48CAE00950702 /* LargeChunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 147AAA8818CD17CE002201E4 /* LargeChunk.h */; settings = {ATTRIBUTES = (Private, ); }; };
</del><span class="cx">                 14DD788D18F48CC600950702 /* BeginTag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1417F64518B54A700076FA3F /* BeginTag.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 14DD788E18F48CCD00950702 /* BoundaryTag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1485655E18A43AF900ED6942 /* BoundaryTag.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 14DD789018F48CEB00950702 /* Sizes.h in Headers */ = {isa = PBXBuildFile; fileRef = 145F6874179DF84100D65598 /* Sizes.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -119,7 +119,7 @@
</span><span class="cx">                 146BEE2118C845AE0002D5A2 /* SegregatedFreeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SegregatedFreeList.cpp; path = bmalloc/SegregatedFreeList.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 1479E21217A1A255006D4E9D /* Vector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = Vector.h; path = bmalloc/Vector.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
</span><span class="cx">                 1479E21417A1A63E006D4E9D /* VMAllocate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = VMAllocate.h; path = bmalloc/VMAllocate.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
</span><del>-                147AAA8818CD17CE002201E4 /* LargeChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LargeChunk.h; path = bmalloc/LargeChunk.h; sourceTree = "<group>"; };
</del><ins>+                147DC6E21CA5B70B00724E8D /* Chunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Chunk.h; path = bmalloc/Chunk.h; sourceTree = "<group>"; };
</ins><span class="cx">                 1485655E18A43AF900ED6942 /* BoundaryTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BoundaryTag.h; path = bmalloc/BoundaryTag.h; sourceTree = "<group>"; };
</span><span class="cx">                 1485656018A43DBA00ED6942 /* ObjectType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectType.h; path = bmalloc/ObjectType.h; sourceTree = "<group>"; };
</span><span class="cx">                 14895D8F1A3A319C0006235D /* Environment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Environment.cpp; path = bmalloc/Environment.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -218,7 +218,6 @@
</span><span class="cx">                                 1417F64618B54A700076FA3F /* EndTag.h */,
</span><span class="cx">                                 143EF9AD1A9FABF6004F5C77 /* FreeList.cpp */,
</span><span class="cx">                                 143EF9AE1A9FABF6004F5C77 /* FreeList.h */,
</span><del>-                                147AAA8818CD17CE002201E4 /* LargeChunk.h */,
</del><span class="cx">                                 14C6216E1A9A9A6200E72293 /* LargeObject.h */,
</span><span class="cx">                                 146BEE2118C845AE0002D5A2 /* SegregatedFreeList.cpp */,
</span><span class="cx">                                 146BEE1E18C841C50002D5A2 /* SegregatedFreeList.h */,
</span><span class="lines">@@ -256,6 +255,7 @@
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><span class="cx">                                 140FA00219CE429C00FFD3C8 /* BumpRange.h */,
</span><ins>+                                147DC6E21CA5B70B00724E8D /* Chunk.h */,
</ins><span class="cx">                                 14895D8F1A3A319C0006235D /* Environment.cpp */,
</span><span class="cx">                                 14895D901A3A319C0006235D /* Environment.h */,
</span><span class="cx">                                 14DA320E18875D9F007269E0 /* Heap.cpp */,
</span><span class="lines">@@ -313,7 +313,6 @@
</span><span class="cx">                         files = (
</span><span class="cx">                                 14DD78CF18F48D7500950702 /* Vector.h in Headers */,
</span><span class="cx">                                 14C919C918FCC59F0028DB43 /* BPlatform.h in Headers */,
</span><del>-                                14DD788C18F48CAE00950702 /* LargeChunk.h in Headers */,
</del><span class="cx">                                 14DD789218F48CFC00950702 /* EndTag.h in Headers */,
</span><span class="cx">                                 1440AFCB1A95261100837FAA /* Zone.h in Headers */,
</span><span class="cx">                                 140FA00519CE4B6800FFD3C8 /* LineMetadata.h in Headers */,
</span><span class="lines">@@ -348,6 +347,7 @@
</span><span class="cx">                                 14DD78C818F48D7500950702 /* FixedVector.h in Headers */,
</span><span class="cx">                                 144C07F51C7B70260051BB6A /* XLargeMap.h in Headers */,
</span><span class="cx">                                 14D2CD9B1AA12CFB00770440 /* VMState.h in Headers */,
</span><ins>+                                147DC6E31CA5B70B00724E8D /* Chunk.h in Headers */,
</ins><span class="cx">                                 14DD78BC18F48D6B00950702 /* SmallLine.h in Headers */,
</span><span class="cx">                                 14DD789818F48D4A00950702 /* Allocator.h in Headers */,
</span><span class="cx">                                 14DD78CB18F48D7500950702 /* PerProcess.h in Headers */,
</span></span></pre>
</div>
</div>
</body>
</html>