Title: [198686] trunk/Source/bmalloc

Diff

Modified: trunk/Source/bmalloc/ChangeLog (198685 => 198686)


--- trunk/Source/bmalloc/ChangeLog	2016-03-25 19:50:13 UTC (rev 198685)
+++ trunk/Source/bmalloc/ChangeLog	2016-03-25 20:30:54 UTC (rev 198686)
@@ -1,3 +1,15 @@
+2016-03-25  Ryan Haddad  <[email protected]>
+
+        Unreviewed, rolling out r198679.
+
+        This change caused flaky LayoutTest crashes
+
+        Reverted changeset:
+
+        "bmalloc: Renamed LargeChunk => Chunk"
+        https://bugs.webkit.org/show_bug.cgi?id=155894
+        http://trac.webkit.org/changeset/198679
+
 2016-03-25  Geoffrey Garen  <[email protected]>
 
         bmalloc: stress_aligned fails when allocating a zero-sized object with XLarge alignment

Modified: trunk/Source/bmalloc/bmalloc/Allocator.cpp (198685 => 198686)


--- trunk/Source/bmalloc/bmalloc/Allocator.cpp	2016-03-25 19:50:13 UTC (rev 198685)
+++ trunk/Source/bmalloc/bmalloc/Allocator.cpp	2016-03-25 20:30:54 UTC (rev 198686)
@@ -25,9 +25,9 @@
 
 #include "Allocator.h"
 #include "BAssert.h"
-#include "Chunk.h"
 #include "Deallocator.h"
 #include "Heap.h"
+#include "LargeChunk.h"
 #include "LargeObject.h"
 #include "PerProcess.h"
 #include "Sizes.h"
@@ -91,7 +91,7 @@
         size = std::max(largeMin, roundUpToMultipleOf<largeAlignment>(size));
         alignment = roundUpToMultipleOf<largeAlignment>(alignment);
         size_t unalignedSize = largeMin + alignment - largeAlignment + size;
-        if (unalignedSize <= largeMax && alignment <= chunkSize / 2) {
+        if (unalignedSize <= largeMax && alignment <= largeChunkSize / 2) {
             std::lock_guard<StaticMutex> lock(PerProcess<Heap>::mutex());
             m_deallocator.processObjectLog(lock);
             return PerProcess<Heap>::getFastCase()->allocateLarge(lock, alignment, size, unalignedSize);

Modified: trunk/Source/bmalloc/bmalloc/BoundaryTag.h (198685 => 198686)


--- trunk/Source/bmalloc/bmalloc/BoundaryTag.h	2016-03-25 19:50:13 UTC (rev 198685)
+++ trunk/Source/bmalloc/bmalloc/BoundaryTag.h	2016-03-25 20:30:54 UTC (rev 198686)
@@ -36,12 +36,12 @@
 
 class BeginTag;
 class EndTag;
-class Chunk;
+class LargeChunk;
 class Range;
 
 class BoundaryTag {
 public:
-    static Range init(Chunk*);
+    static Range init(LargeChunk*);
     static unsigned compactBegin(void*);
 
     bool isFree() { return m_isFree; }

Deleted: trunk/Source/bmalloc/bmalloc/Chunk.h (198685 => 198686)


--- trunk/Source/bmalloc/bmalloc/Chunk.h	2016-03-25 19:50:13 UTC (rev 198685)
+++ trunk/Source/bmalloc/bmalloc/Chunk.h	2016-03-25 20:30:54 UTC (rev 198686)
@@ -1,239 +0,0 @@
-/*
- * 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

Modified: trunk/Source/bmalloc/bmalloc/Deallocator.cpp (198685 => 198686)


--- trunk/Source/bmalloc/bmalloc/Deallocator.cpp	2016-03-25 19:50:13 UTC (rev 198685)
+++ trunk/Source/bmalloc/bmalloc/Deallocator.cpp	2016-03-25 20:30:54 UTC (rev 198686)
@@ -24,7 +24,7 @@
  */
 
 #include "BAssert.h"
-#include "Chunk.h"
+#include "LargeChunk.h"
 #include "Deallocator.h"
 #include "Heap.h"
 #include "Inline.h"

Modified: trunk/Source/bmalloc/bmalloc/FreeList.cpp (198685 => 198686)


--- trunk/Source/bmalloc/bmalloc/FreeList.cpp	2016-03-25 19:50:13 UTC (rev 198685)
+++ trunk/Source/bmalloc/bmalloc/FreeList.cpp	2016-03-25 20:30:54 UTC (rev 198686)
@@ -23,8 +23,8 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
+#include "LargeChunk.h"
 #include "FreeList.h"
-#include "Chunk.h"
 #include "Vector.h"
 
 namespace bmalloc {

Modified: trunk/Source/bmalloc/bmalloc/Heap.cpp (198685 => 198686)


--- trunk/Source/bmalloc/bmalloc/Heap.cpp	2016-03-25 19:50:13 UTC (rev 198685)
+++ trunk/Source/bmalloc/bmalloc/Heap.cpp	2016-03-25 20:30:54 UTC (rev 198686)
@@ -25,7 +25,7 @@
 
 #include "Heap.h"
 #include "BumpAllocator.h"
-#include "Chunk.h"
+#include "LargeChunk.h"
 #include "LargeObject.h"
 #include "PerProcess.h"
 #include "SmallLine.h"
@@ -334,7 +334,7 @@
     BASSERT(unalignedSize <= largeMax);
     BASSERT(unalignedSize >= largeMin);
     BASSERT(unalignedSize == roundUpToMultipleOf<largeAlignment>(unalignedSize));
-    BASSERT(alignment <= chunkSize / 2);
+    BASSERT(alignment <= largeChunkSize / 2);
     BASSERT(alignment >= largeAlignment);
     BASSERT(isPowerOfTwo(alignment));
 

Copied: trunk/Source/bmalloc/bmalloc/LargeChunk.h (from rev 198684, trunk/Source/bmalloc/bmalloc/Chunk.h) (0 => 198686)


--- trunk/Source/bmalloc/bmalloc/LargeChunk.h	                        (rev 0)
+++ trunk/Source/bmalloc/bmalloc/LargeChunk.h	2016-03-25 20:30:54 UTC (rev 198686)
@@ -0,0 +1,239 @@
+/*
+ * 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

Modified: trunk/Source/bmalloc/bmalloc/LargeObject.h (198685 => 198686)


--- trunk/Source/bmalloc/bmalloc/LargeObject.h	2016-03-25 19:50:13 UTC (rev 198685)
+++ trunk/Source/bmalloc/bmalloc/LargeObject.h	2016-03-25 20:30:54 UTC (rev 198686)
@@ -27,8 +27,8 @@
 #define LargeObject_h
 
 #include "BeginTag.h"
-#include "Chunk.h"
 #include "EndTag.h"
+#include "LargeChunk.h"
 #include "Range.h"
 
 namespace bmalloc {
@@ -85,16 +85,16 @@
 }
 
 inline LargeObject::LargeObject(void* object)
-    : m_beginTag(Chunk::beginTag(object))
-    , m_endTag(Chunk::endTag(object, m_beginTag->size()))
+    : m_beginTag(LargeChunk::beginTag(object))
+    , m_endTag(LargeChunk::endTag(object, m_beginTag->size()))
     , m_object(object)
 {
     validate();
 }
 
 inline LargeObject::LargeObject(DoNotValidateTag, void* object)
-    : m_beginTag(Chunk::beginTag(object))
-    , m_endTag(Chunk::endTag(object, m_beginTag->size()))
+    : m_beginTag(LargeChunk::beginTag(object))
+    , m_endTag(LargeChunk::endTag(object, m_beginTag->size()))
     , m_object(object)
 {
 }
@@ -194,7 +194,7 @@
         prev->clear();
         beginTag->clear();
 
-        beginTag = Chunk::beginTag(range.begin());
+        beginTag = LargeChunk::beginTag(range.begin());
     }
 
     BeginTag* next = endTag->next();
@@ -206,7 +206,7 @@
         endTag->clear();
         next->clear();
 
-        endTag = Chunk::endTag(range.begin(), range.size());
+        endTag = LargeChunk::endTag(range.begin(), range.size());
     }
 
     beginTag->setRange(range);
@@ -225,9 +225,9 @@
     BASSERT(leftover.size() >= largeMin);
 
     BeginTag* splitBeginTag = m_beginTag;
-    EndTag* splitEndTag = Chunk::endTag(split.begin(), size);
+    EndTag* splitEndTag = LargeChunk::endTag(split.begin(), size);
 
-    BeginTag* leftoverBeginTag = Chunk::beginTag(leftover.begin());
+    BeginTag* leftoverBeginTag = LargeChunk::beginTag(leftover.begin());
     EndTag* leftoverEndTag = m_endTag;
 
     splitBeginTag->setRange(split);

Modified: trunk/Source/bmalloc/bmalloc/Object.h (198685 => 198686)


--- trunk/Source/bmalloc/bmalloc/Object.h	2016-03-25 19:50:13 UTC (rev 198685)
+++ trunk/Source/bmalloc/bmalloc/Object.h	2016-03-25 20:30:54 UTC (rev 198686)
@@ -28,16 +28,16 @@
 
 namespace bmalloc {
 
-class Chunk;
+class LargeChunk;
 class SmallLine;
 class SmallPage;
 
 class Object {
 public:
     Object(void*);
-    Object(Chunk*, void*);
+    Object(LargeChunk*, void*);
     
-    Chunk* chunk() { return m_chunk; }
+    LargeChunk* chunk() { return m_chunk; }
     void* begin();
     void* pageBegin();
 
@@ -45,7 +45,7 @@
     SmallPage* page();
 
 private:
-    Chunk* m_chunk;
+    LargeChunk* m_chunk;
     size_t m_offset;
 };
 

Modified: trunk/Source/bmalloc/bmalloc/ObjectType.cpp (198685 => 198686)


--- trunk/Source/bmalloc/bmalloc/ObjectType.cpp	2016-03-25 19:50:13 UTC (rev 198685)
+++ trunk/Source/bmalloc/bmalloc/ObjectType.cpp	2016-03-25 20:30:54 UTC (rev 198686)
@@ -25,7 +25,7 @@
 
 #include "ObjectType.h"
 
-#include "Chunk.h"
+#include "LargeChunk.h"
 #include "Object.h"
 
 namespace bmalloc {

Modified: trunk/Source/bmalloc/bmalloc/Sizes.h (198685 => 198686)


--- trunk/Source/bmalloc/bmalloc/Sizes.h	2016-03-25 19:50:13 UTC (rev 198685)
+++ trunk/Source/bmalloc/bmalloc/Sizes.h	2016-03-25 20:30:54 UTC (rev 198686)
@@ -58,15 +58,15 @@
     static const size_t smallMax = 1 * kB;
     static const size_t maskSizeClassMax = 512;
 
-    static const size_t chunkSize = 2 * MB;
-    static const size_t chunkMask = ~(chunkSize - 1ul);
+    static const size_t largeChunkSize = 2 * MB;
+    static const size_t largeChunkMask = ~(largeChunkSize - 1ul);
 
     static const size_t largeAlignment = 64;
     static const size_t largeMin = smallMax;
-    static const size_t largeObjectMax = chunkSize;
+    static const size_t largeObjectMax = largeChunkSize;
     static const size_t largeMax = largeObjectMax / 2;
 
-    static const size_t xLargeAlignment = chunkSize;
+    static const size_t xLargeAlignment = largeChunkSize;
     static const size_t xLargeMask = ~(xLargeAlignment - 1);
     static const size_t xLargeMax = std::numeric_limits<size_t>::max() - xLargeAlignment; // Make sure that rounding up to xLargeAlignment does not overflow.
 

Added: trunk/Source/bmalloc/bmalloc/SmallAllocator.h ( => )


Modified: trunk/Source/bmalloc/bmalloc/VMHeap.cpp
===================================================================
--- trunk/Source/bmalloc/bmalloc/VMHeap.cpp	2016-03-25 19:50:13 UTC (rev 198685)
+++ trunk/Source/bmalloc/bmalloc/VMHeap.cpp	2016-03-25 20:30:54 UTC (rev 198686)
@@ -35,16 +35,16 @@
 {
 }
 
-LargeObject VMHeap::allocateChunk(std::lock_guard<StaticMutex>& lock)
+LargeObject VMHeap::allocateLargeChunk(std::lock_guard<StaticMutex>& lock)
 {
-    Chunk* chunk =
-        new (vmAllocate(chunkSize, chunkSize)) Chunk(lock);
+    LargeChunk* largeChunk =
+        new (vmAllocate(largeChunkSize, largeChunkSize)) LargeChunk(lock);
 
 #if BOS(DARWIN)
-    m_zone.addChunk(chunk);
+    m_zone.addLargeChunk(largeChunk);
 #endif
 
-    return LargeObject(chunk->begin());
+    return LargeObject(largeChunk->begin());
 }
 
 } // namespace bmalloc

Modified: trunk/Source/bmalloc/bmalloc/VMHeap.h (198685 => 198686)


--- trunk/Source/bmalloc/bmalloc/VMHeap.h	2016-03-25 19:50:13 UTC (rev 198685)
+++ trunk/Source/bmalloc/bmalloc/VMHeap.h	2016-03-25 20:30:54 UTC (rev 198686)
@@ -27,8 +27,8 @@
 #define VMHeap_h
 
 #include "AsyncTask.h"
-#include "Chunk.h"
 #include "FixedVector.h"
+#include "LargeChunk.h"
 #include "LargeObject.h"
 #include "Range.h"
 #include "SegregatedFreeList.h"
@@ -54,7 +54,7 @@
     void deallocateLargeObject(std::unique_lock<StaticMutex>&, LargeObject);
     
 private:
-    LargeObject allocateChunk(std::lock_guard<StaticMutex>&);
+    LargeObject allocateLargeChunk(std::lock_guard<StaticMutex>&);
 
     SegregatedFreeList m_largeObjects;
 
@@ -69,7 +69,7 @@
         return largeObject;
 
     BASSERT(size <= largeMax);
-    return allocateChunk(lock);
+    return allocateLargeChunk(lock);
 }
 
 inline LargeObject VMHeap::allocateLargeObject(std::lock_guard<StaticMutex>& lock, size_t alignment, size_t size, size_t unalignedSize)
@@ -78,7 +78,7 @@
         return largeObject;
 
     BASSERT(unalignedSize <= largeMax);
-    return allocateChunk(lock);
+    return allocateLargeChunk(lock);
 }
 
 inline void VMHeap::deallocateLargeObject(std::unique_lock<StaticMutex>& lock, LargeObject largeObject)

Modified: trunk/Source/bmalloc/bmalloc/Zone.cpp (198685 => 198686)


--- trunk/Source/bmalloc/bmalloc/Zone.cpp	2016-03-25 19:50:13 UTC (rev 198685)
+++ trunk/Source/bmalloc/bmalloc/Zone.cpp	2016-03-25 20:30:54 UTC (rev 198686)
@@ -88,8 +88,8 @@
 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)
 {
     Zone remoteZone(task, reader, zone_address);
-    for (auto* chunk : remoteZone.chunks()) {
-        vm_range_t range = { reinterpret_cast<vm_address_t>(chunk), chunkSize };
+    for (auto* largeChunk : remoteZone.largeChunks()) {
+        vm_range_t range = { reinterpret_cast<vm_address_t>(largeChunk), largeChunkSize };
 
         if ((type_mask & MALLOC_PTR_REGION_RANGE_TYPE))
             (*recorder)(task, context, MALLOC_PTR_REGION_RANGE_TYPE, &range, 1);

Modified: trunk/Source/bmalloc/bmalloc/Zone.h (198685 => 198686)


--- trunk/Source/bmalloc/bmalloc/Zone.h	2016-03-25 19:50:13 UTC (rev 198685)
+++ trunk/Source/bmalloc/bmalloc/Zone.h	2016-03-25 20:30:54 UTC (rev 198686)
@@ -31,7 +31,7 @@
 
 namespace bmalloc {
 
-class Chunk;
+class LargeChunk;
 
 class Zone : public malloc_zone_t {
 public:
@@ -41,30 +41,30 @@
     Zone();
     Zone(task_t, memory_reader_t, vm_address_t);
 
-    void addChunk(Chunk*);
-    FixedVector<Chunk*, capacity>& chunks() { return m_chunks; }
+    void addLargeChunk(LargeChunk*);
+    FixedVector<LargeChunk*, capacity>& largeChunks() { return m_largeChunks; }
     
 private:
     // This vector has two purposes:
-    //     (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
+    //     (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
     //         ensuring that the leaks tool will scan it. (The leaks tool
     //         conservatively scans all writeable VM regions that are not malloc
     //         regions, and then scans malloc regions using the introspection API.)
     // This prevents the leaks tool from reporting false positive leaks for
     // objects pointed to from bmalloc memory -- though it also prevents the
     // leaks tool from finding any leaks in bmalloc memory.
-    FixedVector<Chunk*, capacity> m_chunks;
+    FixedVector<LargeChunk*, capacity> m_largeChunks;
 };
 
-inline void Zone::addChunk(Chunk* chunk)
+inline void Zone::addLargeChunk(LargeChunk* largeChunk)
 {
-    if (m_chunks.size() == m_chunks.capacity())
+    if (m_largeChunks.size() == m_largeChunks.capacity())
         return;
     
-    m_chunks.push(chunk);
+    m_largeChunks.push(largeChunk);
 }
 
 } // namespace bmalloc

Modified: trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj (198685 => 198686)


--- trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj	2016-03-25 19:50:13 UTC (rev 198685)
+++ trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj	2016-03-25 20:30:54 UTC (rev 198686)
@@ -25,13 +25,13 @@
 		144C07F41C7B70260051BB6A /* XLargeMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 144C07F21C7B70260051BB6A /* XLargeMap.cpp */; };
 		144C07F51C7B70260051BB6A /* XLargeMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 144C07F31C7B70260051BB6A /* XLargeMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		146041E71C7FF2EF00E9F94E /* SortedVector.h in Headers */ = {isa = PBXBuildFile; fileRef = 146041E61C7FF2EF00E9F94E /* SortedVector.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		147DC6E31CA5B70B00724E8D /* Chunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 147DC6E21CA5B70B00724E8D /* Chunk.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		14895D911A3A319C0006235D /* Environment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14895D8F1A3A319C0006235D /* Environment.cpp */; };
 		14895D921A3A319C0006235D /* Environment.h in Headers */ = {isa = PBXBuildFile; fileRef = 14895D901A3A319C0006235D /* Environment.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		14C6216F1A9A9A6200E72293 /* LargeObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 14C6216E1A9A9A6200E72293 /* LargeObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		14C919C918FCC59F0028DB43 /* BPlatform.h in Headers */ = {isa = PBXBuildFile; fileRef = 14C919C818FCC59F0028DB43 /* BPlatform.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		14CC394C18EA8858004AFE34 /* libbmalloc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14F271BE18EA3963008C152F /* libbmalloc.a */; };
 		14D2CD9B1AA12CFB00770440 /* VMState.h in Headers */ = {isa = PBXBuildFile; fileRef = 14D2CD9A1AA12CFB00770440 /* VMState.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		14DD788C18F48CAE00950702 /* LargeChunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 147AAA8818CD17CE002201E4 /* LargeChunk.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		14DD788D18F48CC600950702 /* BeginTag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1417F64518B54A700076FA3F /* BeginTag.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		14DD788E18F48CCD00950702 /* BoundaryTag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1485655E18A43AF900ED6942 /* BoundaryTag.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		14DD789018F48CEB00950702 /* Sizes.h in Headers */ = {isa = PBXBuildFile; fileRef = 145F6874179DF84100D65598 /* Sizes.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -119,7 +119,7 @@
 		146BEE2118C845AE0002D5A2 /* SegregatedFreeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SegregatedFreeList.cpp; path = bmalloc/SegregatedFreeList.cpp; sourceTree = "<group>"; };
 		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; };
 		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; };
-		147DC6E21CA5B70B00724E8D /* Chunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Chunk.h; path = bmalloc/Chunk.h; sourceTree = "<group>"; };
+		147AAA8818CD17CE002201E4 /* LargeChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LargeChunk.h; path = bmalloc/LargeChunk.h; sourceTree = "<group>"; };
 		1485655E18A43AF900ED6942 /* BoundaryTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BoundaryTag.h; path = bmalloc/BoundaryTag.h; sourceTree = "<group>"; };
 		1485656018A43DBA00ED6942 /* ObjectType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectType.h; path = bmalloc/ObjectType.h; sourceTree = "<group>"; };
 		14895D8F1A3A319C0006235D /* Environment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Environment.cpp; path = bmalloc/Environment.cpp; sourceTree = "<group>"; };
@@ -218,6 +218,7 @@
 				1417F64618B54A700076FA3F /* EndTag.h */,
 				143EF9AD1A9FABF6004F5C77 /* FreeList.cpp */,
 				143EF9AE1A9FABF6004F5C77 /* FreeList.h */,
+				147AAA8818CD17CE002201E4 /* LargeChunk.h */,
 				14C6216E1A9A9A6200E72293 /* LargeObject.h */,
 				146BEE2118C845AE0002D5A2 /* SegregatedFreeList.cpp */,
 				146BEE1E18C841C50002D5A2 /* SegregatedFreeList.h */,
@@ -255,7 +256,6 @@
 			isa = PBXGroup;
 			children = (
 				140FA00219CE429C00FFD3C8 /* BumpRange.h */,
-				147DC6E21CA5B70B00724E8D /* Chunk.h */,
 				14895D8F1A3A319C0006235D /* Environment.cpp */,
 				14895D901A3A319C0006235D /* Environment.h */,
 				14DA320E18875D9F007269E0 /* Heap.cpp */,
@@ -313,6 +313,7 @@
 			files = (
 				14DD78CF18F48D7500950702 /* Vector.h in Headers */,
 				14C919C918FCC59F0028DB43 /* BPlatform.h in Headers */,
+				14DD788C18F48CAE00950702 /* LargeChunk.h in Headers */,
 				14DD789218F48CFC00950702 /* EndTag.h in Headers */,
 				1440AFCB1A95261100837FAA /* Zone.h in Headers */,
 				140FA00519CE4B6800FFD3C8 /* LineMetadata.h in Headers */,
@@ -347,7 +348,6 @@
 				14DD78C818F48D7500950702 /* FixedVector.h in Headers */,
 				144C07F51C7B70260051BB6A /* XLargeMap.h in Headers */,
 				14D2CD9B1AA12CFB00770440 /* VMState.h in Headers */,
-				147DC6E31CA5B70B00724E8D /* Chunk.h in Headers */,
 				14DD78BC18F48D6B00950702 /* SmallLine.h in Headers */,
 				14DD789818F48D4A00950702 /* Allocator.h in Headers */,
 				14DD78CB18F48D7500950702 /* PerProcess.h in Headers */,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to