bmalloc: Renamed LargeChunk => Chunk
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Mar 2016 18:32:11 +0000 (18:32 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Mar 2016 18:32:11 +0000 (18:32 +0000)
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198679 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
Source/bmalloc/ChangeLog
Source/bmalloc/bmalloc.xcodeproj/project.pbxproj
Source/bmalloc/bmalloc/Allocator.cpp
Source/bmalloc/bmalloc/BoundaryTag.h
Source/bmalloc/bmalloc/Chunk.h [moved from Source/bmalloc/bmalloc/LargeChunk.h with 77% similarity]
Source/bmalloc/bmalloc/Deallocator.cpp
Source/bmalloc/bmalloc/FreeList.cpp
Source/bmalloc/bmalloc/Heap.cpp
Source/bmalloc/bmalloc/LargeObject.h
Source/bmalloc/bmalloc/Object.h
Source/bmalloc/bmalloc/ObjectType.cpp
Source/bmalloc/bmalloc/Sizes.h
Source/bmalloc/bmalloc/SmallAllocator.h [deleted file]
Source/bmalloc/bmalloc/VMHeap.cpp
Source/bmalloc/bmalloc/VMHeap.h
Source/bmalloc/bmalloc/Zone.cpp
Source/bmalloc/bmalloc/Zone.h

index 23a5f65..401f45d 100644 (file)
@@ -1,3 +1,74 @@
+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.
+
 2016-03-24  Geoffrey Garen  <ggaren@apple.com>
 
         bmalloc: small and large objects should share memory
index efeee50..7ff77d0 100644 (file)
                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, ); }; };
                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; };
-               147AAA8818CD17CE002201E4 /* LargeChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LargeChunk.h; path = bmalloc/LargeChunk.h; sourceTree = "<group>"; };
+               147DC6E21CA5B70B00724E8D /* Chunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Chunk.h; path = bmalloc/Chunk.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>"; };
                                1417F64618B54A700076FA3F /* EndTag.h */,
                                143EF9AD1A9FABF6004F5C77 /* FreeList.cpp */,
                                143EF9AE1A9FABF6004F5C77 /* FreeList.h */,
-                               147AAA8818CD17CE002201E4 /* LargeChunk.h */,
                                14C6216E1A9A9A6200E72293 /* LargeObject.h */,
                                146BEE2118C845AE0002D5A2 /* SegregatedFreeList.cpp */,
                                146BEE1E18C841C50002D5A2 /* SegregatedFreeList.h */,
                        isa = PBXGroup;
                        children = (
                                140FA00219CE429C00FFD3C8 /* BumpRange.h */,
+                               147DC6E21CA5B70B00724E8D /* Chunk.h */,
                                14895D8F1A3A319C0006235D /* Environment.cpp */,
                                14895D901A3A319C0006235D /* Environment.h */,
                                14DA320E18875D9F007269E0 /* Heap.cpp */,
                        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 */,
                                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 */,
index e345b52..d8840e9 100644 (file)
@@ -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 @@ void* Allocator::allocate(size_t alignment, size_t size)
         size = std::max(largeMin, roundUpToMultipleOf<largeAlignment>(size));
         alignment = roundUpToMultipleOf<largeAlignment>(alignment);
         size_t unalignedSize = largeMin + alignment - largeAlignment + size;
-        if (unalignedSize <= largeMax && alignment <= largeChunkSize / 2) {
+        if (unalignedSize <= largeMax && alignment <= chunkSize / 2) {
             std::lock_guard<StaticMutex> lock(PerProcess<Heap>::mutex());
             m_deallocator.processObjectLog(lock);
             return PerProcess<Heap>::getFastCase()->allocateLarge(lock, alignment, size, unalignedSize);
index 5113b51..41e9b5f 100644 (file)
@@ -36,12 +36,12 @@ namespace bmalloc {
 
 class BeginTag;
 class EndTag;
-class LargeChunk;
+class Chunk;
 class Range;
 
 class BoundaryTag {
 public:
-    static Range init(LargeChunk*);
+    static Range init(Chunk*);
     static unsigned compactBegin(void*);
 
     bool isFree() { return m_isFree; }
similarity index 77%
rename from Source/bmalloc/bmalloc/LargeChunk.h
rename to Source/bmalloc/bmalloc/Chunk.h
index 86df802..fc5c3e1 100644 (file)
@@ -23,8 +23,8 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef LargeChunk_h
-#define LargeChunk_h
+#ifndef Chunk_h
+#define Chunk_h
 
 #include "BeginTag.h"
 #include "EndTag.h"
 
 namespace bmalloc {
 
-class LargeChunk {
+class Chunk {
 public:
-    static LargeChunk* get(void*);
+    static Chunk* get(void*);
 
     static BeginTag* beginTag(void*);
     static EndTag* endTag(void*, size_t);
 
-    LargeChunk(std::lock_guard<StaticMutex>&);
+    Chunk(std::lock_guard<StaticMutex>&);
 
     size_t offset(void*);
 
@@ -60,11 +60,11 @@ public:
     SmallPage* pages() { return m_pages.begin(); }
 
     char* begin() { return m_memory; }
-    char* end() { return reinterpret_cast<char*>(this) + largeChunkSize; }
+    char* end() { return reinterpret_cast<char*>(this) + chunkSize; }
 
 private:
-    static const size_t boundaryTagCount = largeChunkSize / largeMin;
-    static_assert(boundaryTagCount > 2, "LargeChunk must have space for two sentinel boundary tags");
+    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
@@ -80,28 +80,28 @@ private:
     //
     // 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<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(LargeChunk) + largeMax <= largeChunkSize, "largeMax is too big");
+static_assert(sizeof(Chunk) + largeMax <= chunkSize, "largeMax is too big");
 static_assert(
-    sizeof(LargeChunk) % vmPageSize + 2 * smallMax <= vmPageSize,
+    sizeof(Chunk) % 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)
+inline Chunk::Chunk(std::lock_guard<StaticMutex>& lock)
 {
     Range range(begin(), end() - begin());
     BASSERT(range.size() <= largeObjectMax);
 
-    BeginTag* beginTag = LargeChunk::beginTag(range.begin());
+    BeginTag* beginTag = Chunk::beginTag(range.begin());
     beginTag->setRange(range);
     beginTag->setFree(true);
     beginTag->setVMState(VMState::Virtual);
 
-    EndTag* endTag = LargeChunk::endTag(range.begin(), range.size());
+    EndTag* endTag = Chunk::endTag(range.begin(), range.size());
     endTag->init(beginTag);
 
     // Mark the left and right edges of our range as allocated. This naturally
@@ -126,21 +126,21 @@ inline LargeChunk::LargeChunk(std::lock_guard<StaticMutex>& lock)
     }
 }
 
-inline LargeChunk* LargeChunk::get(void* object)
+inline Chunk* Chunk::get(void* object)
 {
-    return static_cast<LargeChunk*>(mask(object, largeChunkMask));
+    return static_cast<Chunk*>(mask(object, chunkMask));
 }
 
-inline BeginTag* LargeChunk::beginTag(void* object)
+inline BeginTag* Chunk::beginTag(void* object)
 {
-    LargeChunk* chunk = get(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* LargeChunk::endTag(void* object, size_t size)
+inline EndTag* Chunk::endTag(void* object, size_t size)
 {
-    LargeChunk* chunk = get(object);
+    Chunk* chunk = get(object);
     char* end = static_cast<char*>(object) + size;
 
     // We subtract largeMin before computing the end pointer's boundary tag. An
@@ -151,25 +151,25 @@ inline EndTag* LargeChunk::endTag(void* object, size_t size)
     return static_cast<EndTag*>(&chunk->m_boundaryTags[boundaryTagNumber]);
 }
 
-inline size_t LargeChunk::offset(void* object)
+inline size_t Chunk::offset(void* object)
 {
     BASSERT(object >= this);
-    BASSERT(object < reinterpret_cast<char*>(this) + largeChunkSize);
+    BASSERT(object < reinterpret_cast<char*>(this) + chunkSize);
     return static_cast<char*>(object) - reinterpret_cast<char*>(this);
 }
 
-inline void* LargeChunk::object(size_t offset)
+inline void* Chunk::object(size_t offset)
 {
     return reinterpret_cast<char*>(this) + offset;
 }
 
-inline SmallPage* LargeChunk::page(size_t offset)
+inline SmallPage* Chunk::page(size_t offset)
 {
     size_t pageNumber = offset / vmPageSize;
     return &m_pages[pageNumber];
 }
 
-inline SmallLine* LargeChunk::line(size_t offset)
+inline SmallLine* Chunk::line(size_t offset)
 {
     size_t lineNumber = offset / smallLineSize;
     return &m_lines[lineNumber];
@@ -177,7 +177,7 @@ inline SmallLine* LargeChunk::line(size_t offset)
 
 inline char* SmallLine::begin()
 {
-    LargeChunk* chunk = LargeChunk::get(this);
+    Chunk* chunk = Chunk::get(this);
     size_t lineNumber = this - chunk->lines();
     size_t offset = lineNumber * smallLineSize;
     return &reinterpret_cast<char*>(chunk)[offset];
@@ -190,7 +190,7 @@ inline char* SmallLine::end()
 
 inline SmallLine* SmallPage::begin()
 {
-    LargeChunk* chunk = LargeChunk::get(this);
+    Chunk* chunk = Chunk::get(this);
     size_t pageNumber = this - chunk->pages();
     size_t lineNumber = pageNumber * smallLineCount;
     return &chunk->lines()[lineNumber];
@@ -202,16 +202,16 @@ inline SmallLine* SmallPage::end()
 }
 
 inline Object::Object(void* object)
-    : m_chunk(LargeChunk::get(object))
+    : m_chunk(Chunk::get(object))
     , m_offset(m_chunk->offset(object))
 {
 }
 
-inline Object::Object(LargeChunk* chunk, void* object)
+inline Object::Object(Chunk* chunk, void* object)
     : m_chunk(chunk)
     , m_offset(m_chunk->offset(object))
 {
-    BASSERT(chunk == LargeChunk::get(object));
+    BASSERT(chunk == Chunk::get(object));
 }
 
 inline void* Object::begin()
@@ -236,4 +236,4 @@ inline SmallPage* Object::page()
 
 }; // namespace bmalloc
 
-#endif // LargeChunk
+#endif // Chunk
index 2543555..1c10339 100644 (file)
@@ -24,7 +24,7 @@
  */
 
 #include "BAssert.h"
-#include "LargeChunk.h"
+#include "Chunk.h"
 #include "Deallocator.h"
 #include "Heap.h"
 #include "Inline.h"
index d6094fe..adc884a 100644 (file)
@@ -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 {
index d799959..5bc7fdd 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "Heap.h"
 #include "BumpAllocator.h"
-#include "LargeChunk.h"
+#include "Chunk.h"
 #include "LargeObject.h"
 #include "PerProcess.h"
 #include "SmallLine.h"
@@ -334,7 +334,7 @@ void* Heap::allocateLarge(std::lock_guard<StaticMutex>& lock, size_t alignment,
     BASSERT(unalignedSize <= largeMax);
     BASSERT(unalignedSize >= largeMin);
     BASSERT(unalignedSize == roundUpToMultipleOf<largeAlignment>(unalignedSize));
-    BASSERT(alignment <= largeChunkSize / 2);
+    BASSERT(alignment <= chunkSize / 2);
     BASSERT(alignment >= largeAlignment);
     BASSERT(isPowerOfTwo(alignment));
 
index cc0bdb7..70d91b2 100644 (file)
@@ -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()
 }
 
 inline LargeObject::LargeObject(void* object)
-    : m_beginTag(LargeChunk::beginTag(object))
-    , m_endTag(LargeChunk::endTag(object, m_beginTag->size()))
+    : m_beginTag(Chunk::beginTag(object))
+    , m_endTag(Chunk::endTag(object, m_beginTag->size()))
     , m_object(object)
 {
     validate();
 }
 
 inline LargeObject::LargeObject(DoNotValidateTag, void* object)
-    : m_beginTag(LargeChunk::beginTag(object))
-    , m_endTag(LargeChunk::endTag(object, m_beginTag->size()))
+    : m_beginTag(Chunk::beginTag(object))
+    , m_endTag(Chunk::endTag(object, m_beginTag->size()))
     , m_object(object)
 {
 }
@@ -194,7 +194,7 @@ inline LargeObject LargeObject::merge() const
         prev->clear();
         beginTag->clear();
 
-        beginTag = LargeChunk::beginTag(range.begin());
+        beginTag = Chunk::beginTag(range.begin());
     }
 
     BeginTag* next = endTag->next();
@@ -206,7 +206,7 @@ inline LargeObject LargeObject::merge() const
         endTag->clear();
         next->clear();
 
-        endTag = LargeChunk::endTag(range.begin(), range.size());
+        endTag = Chunk::endTag(range.begin(), range.size());
     }
 
     beginTag->setRange(range);
@@ -225,9 +225,9 @@ inline std::pair<LargeObject, LargeObject> LargeObject::split(size_t size) const
     BASSERT(leftover.size() >= largeMin);
 
     BeginTag* splitBeginTag = m_beginTag;
-    EndTag* splitEndTag = LargeChunk::endTag(split.begin(), size);
+    EndTag* splitEndTag = Chunk::endTag(split.begin(), size);
 
-    BeginTag* leftoverBeginTag = LargeChunk::beginTag(leftover.begin());
+    BeginTag* leftoverBeginTag = Chunk::beginTag(leftover.begin());
     EndTag* leftoverEndTag = m_endTag;
 
     splitBeginTag->setRange(split);
index 0c0d2e4..cf1cf71 100644 (file)
 
 namespace bmalloc {
 
-class LargeChunk;
+class Chunk;
 class SmallLine;
 class SmallPage;
 
 class Object {
 public:
     Object(void*);
-    Object(LargeChunk*, void*);
+    Object(Chunk*, void*);
     
-    LargeChunk* chunk() { return m_chunk; }
+    Chunk* chunk() { return m_chunk; }
     void* begin();
     void* pageBegin();
 
@@ -45,7 +45,7 @@ public:
     SmallPage* page();
 
 private:
-    LargeChunk* m_chunk;
+    Chunk* m_chunk;
     size_t m_offset;
 };
 
index b1e0fcd..562d84f 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "ObjectType.h"
 
-#include "LargeChunk.h"
+#include "Chunk.h"
 #include "Object.h"
 
 namespace bmalloc {
index e55a925..8feff56 100644 (file)
@@ -58,15 +58,15 @@ namespace Sizes {
     static const size_t smallMax = 1 * kB;
     static const size_t maskSizeClassMax = 512;
 
-    static const size_t largeChunkSize = 2 * MB;
-    static const size_t largeChunkMask = ~(largeChunkSize - 1ul);
+    static const size_t chunkSize = 2 * MB;
+    static const size_t chunkMask = ~(chunkSize - 1ul);
 
     static const size_t largeAlignment = 64;
     static const size_t largeMin = smallMax;
-    static const size_t largeObjectMax = largeChunkSize;
+    static const size_t largeObjectMax = chunkSize;
     static const size_t largeMax = largeObjectMax / 2;
 
-    static const size_t xLargeAlignment = largeChunkSize;
+    static const size_t xLargeAlignment = chunkSize;
     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.
 
diff --git a/Source/bmalloc/bmalloc/SmallAllocator.h b/Source/bmalloc/bmalloc/SmallAllocator.h
deleted file mode 100644 (file)
index e69de29..0000000
index 5b08700..d179041 100644 (file)
@@ -35,16 +35,16 @@ VMHeap::VMHeap()
 {
 }
 
-LargeObject VMHeap::allocateLargeChunk(std::lock_guard<StaticMutex>& lock)
+LargeObject VMHeap::allocateChunk(std::lock_guard<StaticMutex>& lock)
 {
-    LargeChunk* largeChunk =
-        new (vmAllocate(largeChunkSize, largeChunkSize)) LargeChunk(lock);
+    Chunk* chunk =
+        new (vmAllocate(chunkSize, chunkSize)) Chunk(lock);
 
 #if BOS(DARWIN)
-    m_zone.addLargeChunk(largeChunk);
+    m_zone.addChunk(chunk);
 #endif
 
-    return LargeObject(largeChunk->begin());
+    return LargeObject(chunk->begin());
 }
 
 } // namespace bmalloc
index 2113c5e..520e28d 100644 (file)
@@ -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 @@ public:
     void deallocateLargeObject(std::unique_lock<StaticMutex>&, LargeObject);
     
 private:
-    LargeObject allocateLargeChunk(std::lock_guard<StaticMutex>&);
+    LargeObject allocateChunk(std::lock_guard<StaticMutex>&);
 
     SegregatedFreeList m_largeObjects;
 
@@ -69,7 +69,7 @@ inline LargeObject VMHeap::allocateLargeObject(std::lock_guard<StaticMutex>& loc
         return largeObject;
 
     BASSERT(size <= largeMax);
-    return allocateLargeChunk(lock);
+    return allocateChunk(lock);
 }
 
 inline LargeObject VMHeap::allocateLargeObject(std::lock_guard<StaticMutex>& lock, size_t alignment, size_t size, size_t unalignedSize)
@@ -78,7 +78,7 @@ inline LargeObject VMHeap::allocateLargeObject(std::lock_guard<StaticMutex>& loc
         return largeObject;
 
     BASSERT(unalignedSize <= largeMax);
-    return allocateLargeChunk(lock);
+    return allocateChunk(lock);
 }
 
 inline void VMHeap::deallocateLargeObject(std::unique_lock<StaticMutex>& lock, LargeObject largeObject)
index eb7e8d2..7fed65a 100644 (file)
@@ -88,8 +88,8 @@ static size_t zoneSize(malloc_zone_t*, const void*)
 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* largeChunk : remoteZone.largeChunks()) {
-        vm_range_t range = { reinterpret_cast<vm_address_t>(largeChunk), largeChunkSize };
+    for (auto* chunk : remoteZone.chunks()) {
+        vm_range_t range = { reinterpret_cast<vm_address_t>(chunk), chunkSize };
 
         if ((type_mask & MALLOC_PTR_REGION_RANGE_TYPE))
             (*recorder)(task, context, MALLOC_PTR_REGION_RANGE_TYPE, &range, 1);
index 8a29079..2d197f9 100644 (file)
@@ -31,7 +31,7 @@
 
 namespace bmalloc {
 
-class LargeChunk;
+class Chunk;
 
 class Zone : public malloc_zone_t {
 public:
@@ -41,30 +41,30 @@ public:
     Zone();
     Zone(task_t, memory_reader_t, vm_address_t);
 
-    void addLargeChunk(LargeChunk*);
-    FixedVector<LargeChunk*, capacity>& largeChunks() { return m_largeChunks; }
+    void addChunk(Chunk*);
+    FixedVector<Chunk*, capacity>& chunks() { return m_chunks; }
     
 private:
     // This vector has two purposes:
-    //     (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
+    //     (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
     //         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<LargeChunk*, capacity> m_largeChunks;
+    FixedVector<Chunk*, capacity> m_chunks;
 };
 
-inline void Zone::addLargeChunk(LargeChunk* largeChunk)
+inline void Zone::addChunk(Chunk* chunk)
 {
-    if (m_largeChunks.size() == m_largeChunks.capacity())
+    if (m_chunks.size() == m_chunks.capacity())
         return;
     
-    m_largeChunks.push(largeChunk);
+    m_chunks.push(chunk);
 }
 
 } // namespace bmalloc