Changeset 198198 in webkit
- Timestamp:
- Mar 14, 2016, 10:39:35 PM (9 years ago)
- Location:
- trunk/Source/bmalloc
- Files:
-
- 1 deleted
- 9 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/bmalloc/ChangeLog
r197955 r198198 1 2016-03-14 Geoffrey Garen <ggaren@apple.com> 2 3 Unreviewed, rolling out r197955. 4 5 I decided to go in another direction 6 7 Reverted changeset: 8 9 "bmalloc: Rename SmallPage to SmallRun" 10 https://bugs.webkit.org/show_bug.cgi?id=155320 11 http://trac.webkit.org/changeset/197955 12 1 13 2016-03-10 Geoffrey Garen <ggaren@apple.com> 2 14 -
trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj
r197955 r198198 44 44 14DD78BB18F48D6B00950702 /* SmallChunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 147AAA8C18CD36A7002201E4 /* SmallChunk.h */; settings = {ATTRIBUTES = (Private, ); }; }; 45 45 14DD78BC18F48D6B00950702 /* SmallLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1452478618BC757C00F80098 /* SmallLine.h */; settings = {ATTRIBUTES = (Private, ); }; }; 46 14DD78BD18F48D6B00950702 /* Small Run.h in Headers */ = {isa = PBXBuildFile; fileRef = 143E29ED18CAE90500FE8A0F /* SmallRun.h */; settings = {ATTRIBUTES = (Private, ); }; };46 14DD78BD18F48D6B00950702 /* SmallPage.h in Headers */ = {isa = PBXBuildFile; fileRef = 143E29ED18CAE90500FE8A0F /* SmallPage.h */; settings = {ATTRIBUTES = (Private, ); }; }; 47 47 14DD78C518F48D7500950702 /* Algorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 1421A87718EE462A00B4DD68 /* Algorithm.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48 48 14DD78C618F48D7500950702 /* AsyncTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 1417F65218BA88A00076FA3F /* AsyncTask.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 92 92 143CB81A19022BC900B16A45 /* StaticMutex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StaticMutex.cpp; path = bmalloc/StaticMutex.cpp; sourceTree = "<group>"; }; 93 93 143CB81B19022BC900B16A45 /* StaticMutex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StaticMutex.h; path = bmalloc/StaticMutex.h; sourceTree = "<group>"; }; 94 143E29ED18CAE90500FE8A0F /* Small Run.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SmallRun.h; path = bmalloc/SmallRun.h; sourceTree = "<group>"; };94 143E29ED18CAE90500FE8A0F /* SmallPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SmallPage.h; path = bmalloc/SmallPage.h; sourceTree = "<group>"; }; 95 95 143EF9AD1A9FABF6004F5C77 /* FreeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FreeList.cpp; path = bmalloc/FreeList.cpp; sourceTree = "<group>"; }; 96 96 143EF9AE1A9FABF6004F5C77 /* FreeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FreeList.h; path = bmalloc/FreeList.h; sourceTree = "<group>"; }; … … 209 209 147AAA8C18CD36A7002201E4 /* SmallChunk.h */, 210 210 1452478618BC757C00F80098 /* SmallLine.h */, 211 143E29ED18CAE90500FE8A0F /* Small Run.h */,211 143E29ED18CAE90500FE8A0F /* SmallPage.h */, 212 212 ); 213 213 name = "heap: small"; … … 347 347 140FA00319CE429C00FFD3C8 /* BumpRange.h in Headers */, 348 348 14DD78C518F48D7500950702 /* Algorithm.h in Headers */, 349 14DD78BD18F48D6B00950702 /* Small Run.h in Headers */,349 14DD78BD18F48D6B00950702 /* SmallPage.h in Headers */, 350 350 14DD788E18F48CCD00950702 /* BoundaryTag.h in Headers */, 351 351 146041E71C7FF2EF00E9F94E /* SortedVector.h in Headers */, -
trunk/Source/bmalloc/bmalloc/Allocator.cpp
r197955 r198198 115 115 switch (objectType(object)) { 116 116 case Small: { 117 Small Run* run = SmallRun::get(SmallLine::get(object));118 oldSize = objectSize( run->sizeClass());117 SmallPage* page = SmallPage::get(SmallLine::get(object)); 118 oldSize = objectSize(page->sizeClass()); 119 119 break; 120 120 } -
trunk/Source/bmalloc/bmalloc/Heap.cpp
r197955 r198198 31 31 #include "SmallChunk.h" 32 32 #include "SmallLine.h" 33 #include "Small Run.h"33 #include "SmallPage.h" 34 34 #include <thread> 35 35 … … 41 41 , m_scavenger(*this, &Heap::concurrentScavenge) 42 42 { 43 initialize SmallRunMetadata();44 } 45 46 void Heap::initialize SmallRunMetadata()47 { 48 // We assume that m_small RunMetadata is zero-filled.43 initializeLineMetadata(); 44 } 45 46 void Heap::initializeLineMetadata() 47 { 48 // We assume that m_smallLineMetadata is zero-filled. 49 49 50 50 for (size_t size = alignment; size <= smallMax; size += alignment) { 51 51 size_t sizeClass = bmalloc::sizeClass(size); 52 auto& metadata = m_small RunMetadata[sizeClass];52 auto& metadata = m_smallLineMetadata[sizeClass]; 53 53 54 54 size_t object = 0; … … 85 85 waitUntilFalse(lock, sleepDuration, m_isAllocatingPages); 86 86 87 scavengeSmall Runs(lock, sleepDuration);87 scavengeSmallPages(lock, sleepDuration); 88 88 scavengeLargeObjects(lock, sleepDuration); 89 89 scavengeXLargeObjects(lock, sleepDuration); … … 92 92 } 93 93 94 void Heap::scavengeSmall Runs(std::unique_lock<StaticMutex>& lock, std::chrono::milliseconds sleepDuration)95 { 96 while (!m_small Runs.isEmpty()) {97 m_vmHeap.deallocateSmall Run(lock, m_smallRuns.pop());94 void Heap::scavengeSmallPages(std::unique_lock<StaticMutex>& lock, std::chrono::milliseconds sleepDuration) 95 { 96 while (!m_smallPages.isEmpty()) { 97 m_vmHeap.deallocateSmallPage(lock, m_smallPages.pop()); 98 98 waitUntilFalse(lock, sleepDuration, m_isAllocatingPages); 99 99 } … … 127 127 { 128 128 BASSERT(!rangeCache.size()); 129 Small Run* run = allocateSmallRun(lock, sizeClass);130 SmallLine* lines = run->begin();131 BASSERT( run->hasFreeLines(lock));129 SmallPage* page = allocateSmallPage(lock, sizeClass); 130 SmallLine* lines = page->begin(); 131 BASSERT(page->hasFreeLines(lock)); 132 132 133 133 // Find a free line. … … 136 136 continue; 137 137 138 LineMetadata& lineMetadata = m_small RunMetadata[sizeClass][lineNumber];138 LineMetadata& lineMetadata = m_smallLineMetadata[sizeClass][lineNumber]; 139 139 if (!lineMetadata.objectCount) 140 140 continue; 141 141 142 // In a fragmented run, some free ranges might not fit in the cache.142 // In a fragmented page, some free ranges might not fit in the cache. 143 143 if (rangeCache.size() == rangeCache.capacity()) { 144 m_small RunsWithFreeLines[sizeClass].push(run);144 m_smallPagesWithFreeLines[sizeClass].push(page); 145 145 BASSERT(allocator.canAllocate()); 146 146 return; … … 150 150 unsigned short objectCount = lineMetadata.objectCount; 151 151 lines[lineNumber].ref(lock, lineMetadata.objectCount); 152 run->ref(lock);152 page->ref(lock); 153 153 154 154 // Merge with subsequent free lines. … … 157 157 break; 158 158 159 LineMetadata& lineMetadata = m_small RunMetadata[sizeClass][lineNumber];159 LineMetadata& lineMetadata = m_smallLineMetadata[sizeClass][lineNumber]; 160 160 if (!lineMetadata.objectCount) 161 161 continue; … … 163 163 objectCount += lineMetadata.objectCount; 164 164 lines[lineNumber].ref(lock, lineMetadata.objectCount); 165 run->ref(lock);165 page->ref(lock); 166 166 } 167 167 … … 173 173 174 174 BASSERT(allocator.canAllocate()); 175 run->setHasFreeLines(lock, false);176 } 177 178 Small Run* Heap::allocateSmallRun(std::lock_guard<StaticMutex>& lock, size_t sizeClass)179 { 180 if (!m_small RunsWithFreeLines[sizeClass].isEmpty())181 return m_small RunsWithFreeLines[sizeClass].pop();182 183 Small Run* run= [this, &lock]() {184 if (!m_small Runs.isEmpty())185 return m_small Runs.pop();175 page->setHasFreeLines(lock, false); 176 } 177 178 SmallPage* Heap::allocateSmallPage(std::lock_guard<StaticMutex>& lock, size_t sizeClass) 179 { 180 if (!m_smallPagesWithFreeLines[sizeClass].isEmpty()) 181 return m_smallPagesWithFreeLines[sizeClass].pop(); 182 183 SmallPage* page = [this, &lock]() { 184 if (!m_smallPages.isEmpty()) 185 return m_smallPages.pop(); 186 186 187 187 m_isAllocatingPages = true; 188 return m_vmHeap.allocateSmallRun(lock); 188 SmallPage* page = m_vmHeap.allocateSmallPage(lock); 189 return page; 189 190 }(); 190 191 191 run->setSizeClass(sizeClass);192 return run;192 page->setSizeClass(sizeClass); 193 return page; 193 194 } 194 195 … … 196 197 { 197 198 BASSERT(!line->refCount(lock)); 198 Small Run* run = SmallRun::get(line);199 run->deref(lock);200 201 if (! run->hasFreeLines(lock)) {202 run->setHasFreeLines(lock, true);203 m_small RunsWithFreeLines[run->sizeClass()].push(run);204 205 BASSERT( run->refCount(lock));199 SmallPage* page = SmallPage::get(line); 200 page->deref(lock); 201 202 if (!page->hasFreeLines(lock)) { 203 page->setHasFreeLines(lock, true); 204 m_smallPagesWithFreeLines[page->sizeClass()].push(page); 205 206 BASSERT(page->refCount(lock)); 206 207 return; 207 208 } 208 209 209 if ( run->refCount(lock))210 if (page->refCount(lock)) 210 211 return; 211 212 212 m_small RunsWithFreeLines[run->sizeClass()].remove(run);213 m_small Runs.push(run);213 m_smallPagesWithFreeLines[page->sizeClass()].remove(page); 214 m_smallPages.push(page); 214 215 m_scavenger.run(); 215 216 } -
trunk/Source/bmalloc/bmalloc/Heap.h
r197955 r198198 35 35 #include "SmallChunk.h" 36 36 #include "SmallLine.h" 37 #include "Small Run.h"37 #include "SmallPage.h" 38 38 #include "VMHeap.h" 39 39 #include "Vector.h" … … 73 73 ~Heap() = delete; 74 74 75 void initialize SmallRunMetadata();75 void initializeLineMetadata(); 76 76 77 Small Run* allocateSmallRun(std::lock_guard<StaticMutex>&, size_t sizeClass);77 SmallPage* allocateSmallPage(std::lock_guard<StaticMutex>&, size_t sizeClass); 78 78 79 79 void deallocateSmallLine(std::lock_guard<StaticMutex>&, SmallLine*); … … 89 89 90 90 void concurrentScavenge(); 91 void scavengeSmall Runs(std::unique_lock<StaticMutex>&, std::chrono::milliseconds);91 void scavengeSmallPages(std::unique_lock<StaticMutex>&, std::chrono::milliseconds); 92 92 void scavengeLargeObjects(std::unique_lock<StaticMutex>&, std::chrono::milliseconds); 93 93 void scavengeXLargeObjects(std::unique_lock<StaticMutex>&, std::chrono::milliseconds); 94 94 95 std::array< RunMetadata, smallMax / alignment> m_smallRunMetadata;95 std::array<std::array<LineMetadata, smallLineCount>, smallMax / alignment> m_smallLineMetadata; 96 96 97 std::array<List<Small Run>, smallMax / alignment> m_smallRunsWithFreeLines;97 std::array<List<SmallPage>, smallMax / alignment> m_smallPagesWithFreeLines; 98 98 99 List<Small Run> m_smallRuns;99 List<SmallPage> m_smallPages; 100 100 101 101 SegregatedFreeList m_largeObjects; -
trunk/Source/bmalloc/bmalloc/LineMetadata.h
r197955 r198198 34 34 }; 35 35 36 typedef std::array<LineMetadata, smallLineCount> RunMetadata;37 38 36 } // namespace bmalloc 39 37 -
trunk/Source/bmalloc/bmalloc/SmallChunk.h
r197955 r198198 29 29 #include "Sizes.h" 30 30 #include "SmallLine.h" 31 #include "Small Run.h"31 #include "SmallPage.h" 32 32 #include "VMAllocate.h" 33 33 … … 40 40 static SmallChunk* get(void*); 41 41 42 Small Run* begin() { return SmallRun::get(SmallLine::get(m_memory)); }43 Small Run* end() { return m_runs.end(); }42 SmallPage* begin() { return SmallPage::get(SmallLine::get(m_memory)); } 43 SmallPage* end() { return m_pages.end(); } 44 44 45 45 SmallLine* lines() { return m_lines.begin(); } 46 Small Run* runs() { return m_runs.begin(); }46 SmallPage* pages() { return m_pages.begin(); } 47 47 48 48 private: 49 49 std::array<SmallLine, smallChunkSize / smallLineSize> m_lines; 50 std::array<Small Run, smallChunkSize / vmPageSize> m_runs;50 std::array<SmallPage, smallChunkSize / vmPageSize> m_pages; 51 51 char m_memory[] __attribute__((aligned(2 * smallMax + 0))); 52 52 }; … … 64 64 line->ref(lock, 1); 65 65 66 Small Run* page = SmallRun::get(line);66 SmallPage* page = SmallPage::get(line); 67 67 page->ref(lock); 68 68 } 69 69 70 for (Small Run* page = begin(); page != end(); ++page)70 for (SmallPage* page = begin(); page != end(); ++page) 71 71 page->setHasFreeLines(lock, true); 72 72 } … … 99 99 } 100 100 101 inline Small Run* SmallRun::get(SmallLine* line)101 inline SmallPage* SmallPage::get(SmallLine* line) 102 102 { 103 103 SmallChunk* chunk = SmallChunk::get(line); 104 104 size_t lineNumber = line - chunk->lines(); 105 size_t runNumber = lineNumber * smallLineSize / vmPageSize;106 return &chunk-> runs()[runNumber];105 size_t pageNumber = lineNumber * smallLineSize / vmPageSize; 106 return &chunk->pages()[pageNumber]; 107 107 } 108 108 109 inline SmallLine* Small Run::begin()109 inline SmallLine* SmallPage::begin() 110 110 { 111 111 SmallChunk* chunk = SmallChunk::get(this); 112 size_t runNumber = this - chunk->runs();113 size_t lineNumber = runNumber * smallLineCount;112 size_t pageNumber = this - chunk->pages(); 113 size_t lineNumber = pageNumber * smallLineCount; 114 114 return &chunk->lines()[lineNumber]; 115 115 } 116 116 117 inline SmallLine* Small Run::end()117 inline SmallLine* SmallPage::end() 118 118 { 119 119 return begin() + smallLineCount; -
trunk/Source/bmalloc/bmalloc/VMHeap.cpp
r197955 r198198 45 45 SmallChunk* smallChunk = new (m_smallChunks.pop()->smallChunk()) SmallChunk(lock); 46 46 for (auto* it = smallChunk->begin(); it < smallChunk->end(); ++it) 47 m_small Runs.push(it);47 m_smallPages.push(it); 48 48 } 49 49 -
trunk/Source/bmalloc/bmalloc/VMHeap.h
r197955 r198198 51 51 VMHeap(); 52 52 53 Small Run* allocateSmallRun(std::lock_guard<StaticMutex>&);53 SmallPage* allocateSmallPage(std::lock_guard<StaticMutex>&); 54 54 LargeObject allocateLargeObject(std::lock_guard<StaticMutex>&, size_t); 55 55 LargeObject allocateLargeObject(std::lock_guard<StaticMutex>&, size_t, size_t, size_t); 56 56 57 void deallocateSmall Run(std::unique_lock<StaticMutex>&, SmallRun*);57 void deallocateSmallPage(std::unique_lock<StaticMutex>&, SmallPage*); 58 58 void deallocateLargeObject(std::unique_lock<StaticMutex>&, LargeObject); 59 59 … … 63 63 void allocateSuperChunk(std::lock_guard<StaticMutex>&); 64 64 65 List<Small Run> m_smallRuns;65 List<SmallPage> m_smallPages; 66 66 SegregatedFreeList m_largeObjects; 67 67 … … 74 74 }; 75 75 76 inline Small Run* VMHeap::allocateSmallRun(std::lock_guard<StaticMutex>& lock)76 inline SmallPage* VMHeap::allocateSmallPage(std::lock_guard<StaticMutex>& lock) 77 77 { 78 if (m_small Runs.isEmpty())78 if (m_smallPages.isEmpty()) 79 79 allocateSmallChunk(lock); 80 80 81 Small Run* run = m_smallRuns.pop();82 vmAllocatePhysicalPages( run->begin()->begin(), vmPageSize);83 return run;81 SmallPage* page = m_smallPages.pop(); 82 vmAllocatePhysicalPages(page->begin()->begin(), vmPageSize); 83 return page; 84 84 } 85 85 … … 102 102 } 103 103 104 inline void VMHeap::deallocateSmall Run(std::unique_lock<StaticMutex>& lock, SmallRun* run)104 inline void VMHeap::deallocateSmallPage(std::unique_lock<StaticMutex>& lock, SmallPage* page) 105 105 { 106 106 lock.unlock(); 107 vmDeallocatePhysicalPages( run->begin()->begin(), vmPageSize);107 vmDeallocatePhysicalPages(page->begin()->begin(), vmPageSize); 108 108 lock.lock(); 109 109 110 m_small Runs.push(run);110 m_smallPages.push(page); 111 111 } 112 112
Note:
See TracChangeset
for help on using the changeset viewer.