Changeset 196847 in webkit
- Timestamp:
- Feb 19, 2016, 5:06:49 PM (11 years ago)
- Location:
- trunk/Source/bmalloc
- Files:
-
- 1 deleted
- 5 edited
- 3 moved
-
ChangeLog (modified) (1 diff)
-
bmalloc.xcodeproj/project.pbxproj (modified) (8 diffs)
-
bmalloc/Heap.cpp (modified) (4 diffs)
-
bmalloc/Heap.h (modified) (1 diff)
-
bmalloc/Sizes.h (modified) (1 diff)
-
bmalloc/SmallChunk.h (moved) (moved from trunk/Source/bmalloc/bmalloc/Chunk.h ) (3 diffs)
-
bmalloc/SmallLine.h (moved) (moved from trunk/Source/bmalloc/bmalloc/Line.h ) (6 diffs)
-
bmalloc/SmallPage.h (moved) (moved from trunk/Source/bmalloc/bmalloc/Page.h ) (7 diffs)
-
bmalloc/SmallTraits.h (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/bmalloc/ChangeLog
r196845 r196847 1 2016-02-19 Geoffrey Garen <ggaren@apple.com> 2 3 bmalloc: Chunk, Page, and Line don't need to be class templates 4 https://bugs.webkit.org/show_bug.cgi?id=154480 5 6 Reviewed by Gavin Barraclough. 7 8 We needed class templates to distinguish between small and medium, 9 but medium is gone now. 10 11 * bmalloc.xcodeproj/project.pbxproj: 12 * bmalloc/Chunk.h: Removed. 13 * bmalloc/Heap.cpp: 14 (bmalloc::Heap::initializeLineMetadata): 15 (bmalloc::Heap::allocateSmallBumpRanges): 16 * bmalloc/Heap.h: 17 * bmalloc/Line.h: Removed. 18 * bmalloc/Page.h: Removed. 19 * bmalloc/Sizes.h: 20 * bmalloc/SmallChunk.h: Replaced with Source/bmalloc/bmalloc/Chunk.h. 21 (bmalloc::SmallChunk::begin): 22 (bmalloc::SmallChunk::end): 23 (bmalloc::SmallChunk::lines): 24 (bmalloc::SmallChunk::pages): 25 (bmalloc::SmallChunk::get): 26 (bmalloc::SmallLine::get): 27 (bmalloc::SmallLine::begin): 28 (bmalloc::SmallLine::end): 29 (bmalloc::SmallPage::get): 30 (bmalloc::SmallPage::begin): 31 (bmalloc::SmallPage::end): 32 (bmalloc::Chunk::begin): Deleted. 33 (bmalloc::Chunk::end): Deleted. 34 (bmalloc::Chunk::lines): Deleted. 35 (bmalloc::Chunk::pages): Deleted. 36 * bmalloc/SmallLine.h: Replaced with Source/bmalloc/bmalloc/Line.h. 37 (bmalloc::SmallLine::ref): 38 (bmalloc::SmallLine::deref): 39 (bmalloc::Line<Traits>::begin): Deleted. 40 (bmalloc::Line<Traits>::end): Deleted. 41 (bmalloc::Line<Traits>::ref): Deleted. 42 (bmalloc::Line<Traits>::deref): Deleted. 43 * bmalloc/SmallPage.h: Replaced with Source/bmalloc/bmalloc/Page.h. 44 (bmalloc::SmallPage::hasFreeLines): 45 (bmalloc::SmallPage::setHasFreeLines): 46 (bmalloc::SmallPage::ref): 47 (bmalloc::SmallPage::deref): 48 (bmalloc::Page::hasFreeLines): Deleted. 49 (bmalloc::Page::setHasFreeLines): Deleted. 50 (bmalloc::Page<Traits>::ref): Deleted. 51 (bmalloc::Page<Traits>::deref): Deleted. 52 * bmalloc/SmallTraits.h: Removed. 53 1 54 2016-02-18 Geoffrey Garen <ggaren@apple.com> 2 55 -
trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj
r196845 r196847 38 38 14DD789A18F48D4A00950702 /* Deallocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 145F685A179DC90200D65598 /* Deallocator.h */; settings = {ATTRIBUTES = (Private, ); }; }; 39 39 14DD789C18F48D4A00950702 /* BumpAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 1413E462189DE1CD00546D68 /* BumpAllocator.h */; settings = {ATTRIBUTES = (Private, ); }; }; 40 14DD78B418F48D6B00950702 /* Chunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 147AAA9418CE5CA6002201E4 /* Chunk.h */; settings = {ATTRIBUTES = (Private, ); }; };41 14DD78B518F48D6B00950702 /* Line.h in Headers */ = {isa = PBXBuildFile; fileRef = 14DA32071885F9E6007269E0 /* Line.h */; settings = {ATTRIBUTES = (Private, ); }; };42 14DD78BA18F48D6B00950702 /* Page.h in Headers */ = {isa = PBXBuildFile; fileRef = 146BEE2318C980D60002D5A2 /* Page.h */; settings = {ATTRIBUTES = (Private, ); }; };43 40 14DD78BB18F48D6B00950702 /* SmallChunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 147AAA8C18CD36A7002201E4 /* SmallChunk.h */; settings = {ATTRIBUTES = (Private, ); }; }; 44 41 14DD78BC18F48D6B00950702 /* SmallLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1452478618BC757C00F80098 /* SmallLine.h */; settings = {ATTRIBUTES = (Private, ); }; }; 45 42 14DD78BD18F48D6B00950702 /* SmallPage.h in Headers */ = {isa = PBXBuildFile; fileRef = 143E29ED18CAE90500FE8A0F /* SmallPage.h */; settings = {ATTRIBUTES = (Private, ); }; }; 46 14DD78BE18F48D6B00950702 /* SmallTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 147AAA9718CE5FB6002201E4 /* SmallTraits.h */; settings = {ATTRIBUTES = (Private, ); }; };47 43 14DD78C518F48D7500950702 /* Algorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 1421A87718EE462A00B4DD68 /* Algorithm.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48 44 14DD78C618F48D7500950702 /* AsyncTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 1417F65218BA88A00076FA3F /* AsyncTask.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 114 110 146BEE1E18C841C50002D5A2 /* SegregatedFreeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SegregatedFreeList.h; path = bmalloc/SegregatedFreeList.h; sourceTree = "<group>"; }; 115 111 146BEE2118C845AE0002D5A2 /* SegregatedFreeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SegregatedFreeList.cpp; path = bmalloc/SegregatedFreeList.cpp; sourceTree = "<group>"; }; 116 146BEE2318C980D60002D5A2 /* Page.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Page.h; path = bmalloc/Page.h; sourceTree = "<group>"; };117 112 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; }; 118 113 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; }; 119 114 147AAA8818CD17CE002201E4 /* LargeChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LargeChunk.h; path = bmalloc/LargeChunk.h; sourceTree = "<group>"; }; 120 115 147AAA8C18CD36A7002201E4 /* SmallChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SmallChunk.h; path = bmalloc/SmallChunk.h; sourceTree = "<group>"; }; 121 147AAA9418CE5CA6002201E4 /* Chunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Chunk.h; path = bmalloc/Chunk.h; sourceTree = "<group>"; };122 147AAA9718CE5FB6002201E4 /* SmallTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SmallTraits.h; path = bmalloc/SmallTraits.h; sourceTree = "<group>"; };123 116 1485655E18A43AF900ED6942 /* BoundaryTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BoundaryTag.h; path = bmalloc/BoundaryTag.h; sourceTree = "<group>"; }; 124 117 1485656018A43DBA00ED6942 /* ObjectType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectType.h; path = bmalloc/ObjectType.h; sourceTree = "<group>"; }; … … 134 127 14D2CD9A1AA12CFB00770440 /* VMState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VMState.h; path = bmalloc/VMState.h; sourceTree = "<group>"; }; 135 128 14D9DB4517F2447100EAAB79 /* FixedVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = FixedVector.h; path = bmalloc/FixedVector.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 136 14DA32071885F9E6007269E0 /* Line.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = Line.h; path = bmalloc/Line.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };137 129 14DA320C18875B09007269E0 /* Heap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Heap.h; path = bmalloc/Heap.h; sourceTree = "<group>"; }; 138 130 14DA320E18875D9F007269E0 /* Heap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Heap.cpp; path = bmalloc/Heap.cpp; sourceTree = "<group>"; }; … … 194 186 isa = PBXGroup; 195 187 children = ( 196 147AAA9418CE5CA6002201E4 /* Chunk.h */,197 14DA32071885F9E6007269E0 /* Line.h */,198 146BEE2318C980D60002D5A2 /* Page.h */,199 188 147AAA8C18CD36A7002201E4 /* SmallChunk.h */, 200 189 1452478618BC757C00F80098 /* SmallLine.h */, 201 190 143E29ED18CAE90500FE8A0F /* SmallPage.h */, 202 147AAA9718CE5FB6002201E4 /* SmallTraits.h */,203 191 ); 204 192 name = "heap: small | medium"; … … 304 292 buildActionMask = 2147483647; 305 293 files = ( 306 14DD78B518F48D6B00950702 /* Line.h in Headers */,307 294 14DD78CF18F48D7500950702 /* Vector.h in Headers */, 308 295 14C919C918FCC59F0028DB43 /* BPlatform.h in Headers */, … … 312 299 140FA00519CE4B6800FFD3C8 /* LineMetadata.h in Headers */, 313 300 14DD78CC18F48D7500950702 /* PerThread.h in Headers */, 314 14DD78B418F48D6B00950702 /* Chunk.h in Headers */,315 301 14DD78CA18F48D7500950702 /* Mutex.h in Headers */, 316 302 143CB81D19022BC900B16A45 /* StaticMutex.h in Headers */, … … 323 309 14DD789C18F48D4A00950702 /* BumpAllocator.h in Headers */, 324 310 14DD789918F48D4A00950702 /* Cache.h in Headers */, 325 14DD78BE18F48D6B00950702 /* SmallTraits.h in Headers */,326 311 14DD789018F48CEB00950702 /* Sizes.h in Headers */, 327 312 14DD78C718F48D7500950702 /* BAssert.h in Headers */, … … 331 316 14DD78CE18F48D7500950702 /* Syscall.h in Headers */, 332 317 14DD78C618F48D7500950702 /* AsyncTask.h in Headers */, 333 14DD78BA18F48D6B00950702 /* Page.h in Headers */,334 318 14DD78BB18F48D6B00950702 /* SmallChunk.h in Headers */, 335 319 14DD78C918F48D7500950702 /* Inline.h in Headers */, -
trunk/Source/bmalloc/bmalloc/Heap.cpp
r196845 r196847 28 28 #include "LargeChunk.h" 29 29 #include "LargeObject.h" 30 #include "Line.h"31 #include "Page.h"32 30 #include "PerProcess.h" 33 31 #include "SmallChunk.h" 32 #include "SmallLine.h" 33 #include "SmallPage.h" 34 34 #include <thread> 35 35 … … 55 55 size_t line = 0; 56 56 while (object < vmPageSize) { 57 line = object / SmallPage::lineSize;58 size_t leftover = object % SmallPage::lineSize;57 line = object / smallLineSize; 58 size_t leftover = object % smallLineSize; 59 59 60 60 size_t objectCount; 61 61 size_t remainder; 62 divideRoundingUp( SmallPage::lineSize - leftover, size, objectCount, remainder);62 divideRoundingUp(smallLineSize - leftover, size, objectCount, remainder); 63 63 64 64 metadata[line] = { static_cast<unsigned short>(leftover), static_cast<unsigned short>(objectCount) }; … … 115 115 116 116 // Find a free line. 117 for (size_t lineNumber = 0; lineNumber < SmallPage::lineCount; ++lineNumber) {117 for (size_t lineNumber = 0; lineNumber < smallLineCount; ++lineNumber) { 118 118 if (lines[lineNumber].refCount(lock)) 119 119 continue; … … 135 135 136 136 // Merge with subsequent free lines. 137 while (++lineNumber < SmallPage::lineCount) {137 while (++lineNumber < smallLineCount) { 138 138 if (lines[lineNumber].refCount(lock)) 139 139 break; -
trunk/Source/bmalloc/bmalloc/Heap.h
r196845 r196847 87 87 void scavengeLargeObjects(std::unique_lock<StaticMutex>&, std::chrono::milliseconds); 88 88 89 std::array<std::array<LineMetadata, SmallPage::lineCount>, smallMax / alignment> m_smallLineMetadata;89 std::array<std::array<LineMetadata, smallLineCount>, smallMax / alignment> m_smallLineMetadata; 90 90 91 91 std::array<Vector<SmallPage*>, smallMax / alignment> m_smallPagesWithFreeLines; -
trunk/Source/bmalloc/bmalloc/Sizes.h
r196845 r196847 59 59 static const size_t smallMax = 1024; 60 60 static const size_t smallLineSize = 256; 61 static const size_t smallLineCount = vmPageSize / smallLineSize; 61 62 static const size_t smallLineMask = ~(smallLineSize - 1ul); 62 63 -
trunk/Source/bmalloc/bmalloc/SmallChunk.h
r196845 r196847 1 1 /* 2 * Copyright (C) 2014 Apple Inc. All rights reserved.2 * Copyright (C) 2014-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef Chunk_h27 #define Chunk_h26 #ifndef SmallChunk_h 27 #define SmallChunk_h 28 28 29 #include "ObjectType.h"30 29 #include "Sizes.h" 30 #include "SmallLine.h" 31 #include "SmallPage.h" 31 32 #include "VMAllocate.h" 32 33 33 34 namespace bmalloc { 34 35 35 template<class Traits> 36 class Chunk { 36 class SmallChunk { 37 37 public: 38 typedef typename Traits::PageType Page; 39 typedef typename Traits::LineType Line; 38 static SmallChunk* get(void*); 40 39 41 static const size_t lineSize = Traits::lineSize; 42 static const size_t chunkSize = Traits::chunkSize; 43 static const size_t chunkOffset = Traits::chunkOffset; 44 static const uintptr_t chunkMask = Traits::chunkMask; 45 46 static Chunk* get(void*); 47 48 Page* begin() { return Page::get(Line::get(m_memory)); } 49 Page* end() { return &m_pages[pageCount]; } 40 SmallPage* begin() { return SmallPage::get(SmallLine::get(m_memory)); } 41 SmallPage* end() { return &m_pages[pageCount]; } 50 42 51 Line* lines() { return m_lines; }52 Page* pages() { return m_pages; }43 SmallLine* lines() { return m_lines; } 44 SmallPage* pages() { return m_pages; } 53 45 54 46 private: 55 static_assert(!(vmPageSize % lineSize), "vmPageSize must be an even multiple of line size");56 static_assert(!( chunkSize % lineSize), "chunk size must be an even multiple of line size");47 static_assert(!(vmPageSize % smallLineSize), "vmPageSize must be an even multiple of line size"); 48 static_assert(!(smallChunkSize % smallLineSize), "chunk size must be an even multiple of line size"); 57 49 58 static const size_t lineCount = chunkSize / lineSize;59 static const size_t pageCount = chunkSize / vmPageSize;50 static const size_t lineCount = smallChunkSize / smallLineSize; 51 static const size_t pageCount = smallChunkSize / vmPageSize; 60 52 61 Line m_lines[lineCount];62 Page m_pages[pageCount];53 SmallLine m_lines[lineCount]; 54 SmallPage m_pages[pageCount]; 63 55 64 56 // Align to vmPageSize to avoid sharing physical pages with metadata. … … 75 67 }; 76 68 77 template<class Traits> 78 inline auto Chunk<Traits>::get(void* object) -> Chunk* 69 inline SmallChunk* SmallChunk::get(void* object) 79 70 { 80 71 BASSERT(isSmall(object)); 81 return static_cast<Chunk*>(mask(object, chunkMask)); 72 return static_cast<SmallChunk*>(mask(object, smallChunkMask)); 73 } 74 75 inline SmallLine* SmallLine::get(void* object) 76 { 77 BASSERT(isSmall(object)); 78 SmallChunk* chunk = SmallChunk::get(object); 79 size_t lineNumber = (reinterpret_cast<char*>(object) - reinterpret_cast<char*>(chunk)) / smallLineSize; 80 return &chunk->lines()[lineNumber]; 81 } 82 83 inline char* SmallLine::begin() 84 { 85 SmallChunk* chunk = SmallChunk::get(this); 86 size_t lineNumber = this - chunk->lines(); 87 size_t offset = lineNumber * smallLineSize; 88 return &reinterpret_cast<char*>(chunk)[offset]; 89 } 90 91 inline char* SmallLine::end() 92 { 93 return begin() + smallLineSize; 94 } 95 96 inline SmallPage* SmallPage::get(SmallLine* line) 97 { 98 SmallChunk* chunk = SmallChunk::get(line); 99 size_t lineNumber = line - chunk->lines(); 100 size_t pageNumber = lineNumber * smallLineSize / vmPageSize; 101 return &chunk->pages()[pageNumber]; 102 } 103 104 inline SmallLine* SmallPage::begin() 105 { 106 SmallChunk* chunk = SmallChunk::get(this); 107 size_t pageNumber = this - chunk->pages(); 108 size_t lineNumber = pageNumber * smallLineCount; 109 return &chunk->lines()[lineNumber]; 110 } 111 112 inline SmallLine* SmallPage::end() 113 { 114 return begin() + smallLineCount; 82 115 } 83 116 -
trunk/Source/bmalloc/bmalloc/SmallLine.h
r196845 r196847 1 1 /* 2 * Copyright (C) 2014 Apple Inc. All rights reserved.2 * Copyright (C) 2014-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef Line_h27 #define Line_h26 #ifndef SmallLine_h 27 #define SmallLine_h 28 28 29 29 #include "BAssert.h" … … 34 34 namespace bmalloc { 35 35 36 template<class Traits> 37 class Line { 36 class SmallLine { 38 37 public: 39 typedef typename Traits::ChunkType Chunk; 38 static const unsigned char maxRefCount = std::numeric_limits<unsigned char>::max(); 39 static_assert(smallLineSize / alignment < maxRefCount, "maximum object count must fit in Line"); 40 40 41 static const size_t minimumObjectSize = Traits::minimumObjectSize; 42 static const size_t lineSize = Traits::lineSize; 43 44 static const unsigned char maxRefCount = std::numeric_limits<unsigned char>::max(); 45 static_assert(lineSize / minimumObjectSize < maxRefCount, "maximum object count must fit in Line"); 46 47 static Line* get(void*); 41 static SmallLine* get(void*); 48 42 49 43 void ref(std::lock_guard<StaticMutex>&, unsigned char); … … 58 52 }; 59 53 60 template<class Traits> 61 inline auto Line<Traits>::get(void* object) -> Line* 62 { 63 BASSERT(isSmall(object)); 64 Chunk* chunk = Chunk::get(object); 65 size_t lineNumber = (reinterpret_cast<char*>(object) - reinterpret_cast<char*>(chunk)) / lineSize; 66 return &chunk->lines()[lineNumber]; 67 } 68 69 template<class Traits> 70 inline char* Line<Traits>::begin() 71 { 72 Chunk* chunk = Chunk::get(this); 73 size_t lineNumber = this - chunk->lines(); 74 size_t offset = lineNumber * lineSize; 75 return &reinterpret_cast<char*>(chunk)[offset]; 76 } 77 78 template<class Traits> 79 inline char* Line<Traits>::end() 80 { 81 return begin() + lineSize; 82 } 83 84 template<class Traits> 85 inline void Line<Traits>::ref(std::lock_guard<StaticMutex>&, unsigned char refCount) 54 inline void SmallLine::ref(std::lock_guard<StaticMutex>&, unsigned char refCount) 86 55 { 87 56 BASSERT(!m_refCount); … … 90 59 } 91 60 92 template<class Traits> 93 inline bool Line<Traits>::deref(std::lock_guard<StaticMutex>&) 61 inline bool SmallLine::deref(std::lock_guard<StaticMutex>&) 94 62 { 95 63 BASSERT(m_refCount); … … 100 68 } // namespace bmalloc 101 69 102 #endif // Line_h70 #endif // SmallLine_h -
trunk/Source/bmalloc/bmalloc/SmallPage.h
r196845 r196847 1 1 /* 2 * Copyright (C) 2014 Apple Inc. All rights reserved.2 * Copyright (C) 2014-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef Page_h27 #define Page_h26 #ifndef SmallPage_h 27 #define SmallPage_h 28 28 29 29 #include "BAssert.h" … … 34 34 namespace bmalloc { 35 35 36 template<typename Traits> 37 class Page { 36 class SmallPage { 38 37 public: 39 typedef typename Traits::ChunkType Chunk;40 typedef typename Traits::LineType Line;41 42 static const size_t lineSize = Traits::lineSize;43 static const size_t lineCount = vmPageSize / lineSize;44 45 38 static const unsigned char maxRefCount = std::numeric_limits<unsigned char>::max(); 46 static_assert( lineCount < maxRefCount, "maximum line count must fit inPage");39 static_assert(smallLineCount < maxRefCount, "maximum line count must fit in SmallPage"); 47 40 48 static Page* get(Line*);41 static SmallPage* get(SmallLine*); 49 42 50 43 void ref(std::lock_guard<StaticMutex>&); … … 58 51 void setHasFreeLines(std::lock_guard<StaticMutex>&, bool hasFreeLines) { m_hasFreeLines = hasFreeLines; } 59 52 60 Line* begin();61 Line* end();53 SmallLine* begin(); 54 SmallLine* end(); 62 55 63 56 private: … … 67 60 }; 68 61 69 template<typename Traits> 70 inline void Page<Traits>::ref(std::lock_guard<StaticMutex>&) 62 inline void SmallPage::ref(std::lock_guard<StaticMutex>&) 71 63 { 72 64 BASSERT(m_refCount < maxRefCount); … … 74 66 } 75 67 76 template<typename Traits> 77 inline bool Page<Traits>::deref(std::lock_guard<StaticMutex>&) 68 inline bool SmallPage::deref(std::lock_guard<StaticMutex>&) 78 69 { 79 70 BASSERT(m_refCount); … … 82 73 } 83 74 84 template<typename Traits>85 inline auto Page<Traits>::get(Line* line) -> Page*86 {87 Chunk* chunk = Chunk::get(line);88 size_t lineNumber = line - chunk->lines();89 size_t pageNumber = lineNumber * lineSize / vmPageSize;90 return &chunk->pages()[pageNumber];91 }92 93 template<typename Traits>94 inline auto Page<Traits>::begin() -> Line*95 {96 Chunk* chunk = Chunk::get(this);97 size_t pageNumber = this - chunk->pages();98 size_t lineNumber = pageNumber * lineCount;99 return &chunk->lines()[lineNumber];100 }101 102 template<typename Traits>103 inline auto Page<Traits>::end() -> Line*104 {105 return begin() + lineCount;106 }107 108 75 } // namespace bmalloc 109 76 110 #endif // Page_h77 #endif // SmallPage_h
Note:
See TracChangeset
for help on using the changeset viewer.