Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
bmalloc: Chunk, Page, and Line don't need to be class templates
https://bugs.webkit.org/show_bug.cgi?id=154480

Reviewed by Gavin Barraclough.

We needed class templates to distinguish between small and medium,
but medium is gone now.

* bmalloc.xcodeproj/project.pbxproj:
* bmalloc/Chunk.h: Removed.
* bmalloc/Heap.cpp:
(bmalloc::Heap::initializeLineMetadata):
(bmalloc::Heap::allocateSmallBumpRanges):
* bmalloc/Heap.h:
* bmalloc/Line.h: Removed.
* bmalloc/Page.h: Removed.
* bmalloc/Sizes.h:
* bmalloc/SmallChunk.h: Replaced with Source/bmalloc/bmalloc/Chunk.h.
(bmalloc::SmallChunk::begin):
(bmalloc::SmallChunk::end):
(bmalloc::SmallChunk::lines):
(bmalloc::SmallChunk::pages):
(bmalloc::SmallChunk::get):
(bmalloc::SmallLine::get):
(bmalloc::SmallLine::begin):
(bmalloc::SmallLine::end):
(bmalloc::SmallPage::get):
(bmalloc::SmallPage::begin):
(bmalloc::SmallPage::end):
(bmalloc::Chunk::begin): Deleted.
(bmalloc::Chunk::end): Deleted.
(bmalloc::Chunk::lines): Deleted.
(bmalloc::Chunk::pages): Deleted.
* bmalloc/SmallLine.h: Replaced with Source/bmalloc/bmalloc/Line.h.
(bmalloc::SmallLine::ref):
(bmalloc::SmallLine::deref):
(bmalloc::Line<Traits>::begin): Deleted.
(bmalloc::Line<Traits>::end): Deleted.
(bmalloc::Line<Traits>::ref): Deleted.
(bmalloc::Line<Traits>::deref): Deleted.
* bmalloc/SmallPage.h: Replaced with Source/bmalloc/bmalloc/Page.h.
(bmalloc::SmallPage::hasFreeLines):
(bmalloc::SmallPage::setHasFreeLines):
(bmalloc::SmallPage::ref):
(bmalloc::SmallPage::deref):
(bmalloc::Page::hasFreeLines): Deleted.
(bmalloc::Page::setHasFreeLines): Deleted.
(bmalloc::Page<Traits>::ref): Deleted.
(bmalloc::Page<Traits>::deref): Deleted.
* bmalloc/SmallTraits.h: Removed.


Canonical link: https://commits.webkit.org/172589@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196847 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
geoffreygaren committed Feb 20, 2016
1 parent ecae77d commit 1e5abb6
Show file tree
Hide file tree
Showing 12 changed files with 225 additions and 386 deletions.
53 changes: 53 additions & 0 deletions Source/bmalloc/ChangeLog
@@ -1,3 +1,56 @@
2016-02-19 Geoffrey Garen <ggaren@apple.com>

bmalloc: Chunk, Page, and Line don't need to be class templates
https://bugs.webkit.org/show_bug.cgi?id=154480

Reviewed by Gavin Barraclough.

We needed class templates to distinguish between small and medium,
but medium is gone now.

* bmalloc.xcodeproj/project.pbxproj:
* bmalloc/Chunk.h: Removed.
* bmalloc/Heap.cpp:
(bmalloc::Heap::initializeLineMetadata):
(bmalloc::Heap::allocateSmallBumpRanges):
* bmalloc/Heap.h:
* bmalloc/Line.h: Removed.
* bmalloc/Page.h: Removed.
* bmalloc/Sizes.h:
* bmalloc/SmallChunk.h: Replaced with Source/bmalloc/bmalloc/Chunk.h.
(bmalloc::SmallChunk::begin):
(bmalloc::SmallChunk::end):
(bmalloc::SmallChunk::lines):
(bmalloc::SmallChunk::pages):
(bmalloc::SmallChunk::get):
(bmalloc::SmallLine::get):
(bmalloc::SmallLine::begin):
(bmalloc::SmallLine::end):
(bmalloc::SmallPage::get):
(bmalloc::SmallPage::begin):
(bmalloc::SmallPage::end):
(bmalloc::Chunk::begin): Deleted.
(bmalloc::Chunk::end): Deleted.
(bmalloc::Chunk::lines): Deleted.
(bmalloc::Chunk::pages): Deleted.
* bmalloc/SmallLine.h: Replaced with Source/bmalloc/bmalloc/Line.h.
(bmalloc::SmallLine::ref):
(bmalloc::SmallLine::deref):
(bmalloc::Line<Traits>::begin): Deleted.
(bmalloc::Line<Traits>::end): Deleted.
(bmalloc::Line<Traits>::ref): Deleted.
(bmalloc::Line<Traits>::deref): Deleted.
* bmalloc/SmallPage.h: Replaced with Source/bmalloc/bmalloc/Page.h.
(bmalloc::SmallPage::hasFreeLines):
(bmalloc::SmallPage::setHasFreeLines):
(bmalloc::SmallPage::ref):
(bmalloc::SmallPage::deref):
(bmalloc::Page::hasFreeLines): Deleted.
(bmalloc::Page::setHasFreeLines): Deleted.
(bmalloc::Page<Traits>::ref): Deleted.
(bmalloc::Page<Traits>::deref): Deleted.
* bmalloc/SmallTraits.h: Removed.

2016-02-18 Geoffrey Garen <ggaren@apple.com>

bmalloc: Remove the concept of medium objects
Expand Down
16 changes: 0 additions & 16 deletions Source/bmalloc/bmalloc.xcodeproj/project.pbxproj
Expand Up @@ -37,13 +37,9 @@
14DD789918F48D4A00950702 /* Cache.h in Headers */ = {isa = PBXBuildFile; fileRef = 144469E517A46BFE00F9EA1D /* Cache.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD789A18F48D4A00950702 /* Deallocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 145F685A179DC90200D65598 /* Deallocator.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD789C18F48D4A00950702 /* BumpAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 1413E462189DE1CD00546D68 /* BumpAllocator.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD78B418F48D6B00950702 /* Chunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 147AAA9418CE5CA6002201E4 /* Chunk.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD78B518F48D6B00950702 /* Line.h in Headers */ = {isa = PBXBuildFile; fileRef = 14DA32071885F9E6007269E0 /* Line.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD78BA18F48D6B00950702 /* Page.h in Headers */ = {isa = PBXBuildFile; fileRef = 146BEE2318C980D60002D5A2 /* Page.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD78BB18F48D6B00950702 /* SmallChunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 147AAA8C18CD36A7002201E4 /* SmallChunk.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD78BC18F48D6B00950702 /* SmallLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1452478618BC757C00F80098 /* SmallLine.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD78BD18F48D6B00950702 /* SmallPage.h in Headers */ = {isa = PBXBuildFile; fileRef = 143E29ED18CAE90500FE8A0F /* SmallPage.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD78BE18F48D6B00950702 /* SmallTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 147AAA9718CE5FB6002201E4 /* SmallTraits.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD78C518F48D7500950702 /* Algorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 1421A87718EE462A00B4DD68 /* Algorithm.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD78C618F48D7500950702 /* AsyncTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 1417F65218BA88A00076FA3F /* AsyncTask.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD78C718F48D7500950702 /* BAssert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1413E468189EEDE400546D68 /* BAssert.h */; settings = {ATTRIBUTES = (Private, ); }; };
Expand Down Expand Up @@ -113,13 +109,10 @@
145F6878179E3A4400D65598 /* Range.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = Range.h; path = bmalloc/Range.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
146BEE1E18C841C50002D5A2 /* SegregatedFreeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SegregatedFreeList.h; path = bmalloc/SegregatedFreeList.h; sourceTree = "<group>"; };
146BEE2118C845AE0002D5A2 /* SegregatedFreeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SegregatedFreeList.cpp; path = bmalloc/SegregatedFreeList.cpp; sourceTree = "<group>"; };
146BEE2318C980D60002D5A2 /* Page.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Page.h; path = bmalloc/Page.h; 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>"; };
147AAA8C18CD36A7002201E4 /* SmallChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SmallChunk.h; path = bmalloc/SmallChunk.h; sourceTree = "<group>"; };
147AAA9418CE5CA6002201E4 /* Chunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Chunk.h; path = bmalloc/Chunk.h; sourceTree = "<group>"; };
147AAA9718CE5FB6002201E4 /* SmallTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SmallTraits.h; path = bmalloc/SmallTraits.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>"; };
Expand All @@ -133,7 +126,6 @@
14CC394418EA8743004AFE34 /* libmbmalloc.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libmbmalloc.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
14D2CD9A1AA12CFB00770440 /* VMState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VMState.h; path = bmalloc/VMState.h; sourceTree = "<group>"; };
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; };
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; };
14DA320C18875B09007269E0 /* Heap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Heap.h; path = bmalloc/Heap.h; sourceTree = "<group>"; };
14DA320E18875D9F007269E0 /* Heap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Heap.cpp; path = bmalloc/Heap.cpp; sourceTree = "<group>"; };
14F271BE18EA3963008C152F /* libbmalloc.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libbmalloc.a; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -193,13 +185,9 @@
147AAA9A18CE5FD3002201E4 /* heap: small | medium */ = {
isa = PBXGroup;
children = (
147AAA9418CE5CA6002201E4 /* Chunk.h */,
14DA32071885F9E6007269E0 /* Line.h */,
146BEE2318C980D60002D5A2 /* Page.h */,
147AAA8C18CD36A7002201E4 /* SmallChunk.h */,
1452478618BC757C00F80098 /* SmallLine.h */,
143E29ED18CAE90500FE8A0F /* SmallPage.h */,
147AAA9718CE5FB6002201E4 /* SmallTraits.h */,
);
name = "heap: small | medium";
sourceTree = "<group>";
Expand Down Expand Up @@ -303,15 +291,13 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
14DD78B518F48D6B00950702 /* Line.h in Headers */,
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 */,
14DD78CC18F48D7500950702 /* PerThread.h in Headers */,
14DD78B418F48D6B00950702 /* Chunk.h in Headers */,
14DD78CA18F48D7500950702 /* Mutex.h in Headers */,
143CB81D19022BC900B16A45 /* StaticMutex.h in Headers */,
1448C30118F3754C00502839 /* bmalloc.h in Headers */,
Expand All @@ -322,15 +308,13 @@
14DD78CD18F48D7500950702 /* Range.h in Headers */,
14DD789C18F48D4A00950702 /* BumpAllocator.h in Headers */,
14DD789918F48D4A00950702 /* Cache.h in Headers */,
14DD78BE18F48D6B00950702 /* SmallTraits.h in Headers */,
14DD789018F48CEB00950702 /* Sizes.h in Headers */,
14DD78C718F48D7500950702 /* BAssert.h in Headers */,
14DD78D018F48D7500950702 /* VMAllocate.h in Headers */,
1440AFC91A95142400837FAA /* SuperChunk.h in Headers */,
143EF9B01A9FABF6004F5C77 /* FreeList.h in Headers */,
14DD78CE18F48D7500950702 /* Syscall.h in Headers */,
14DD78C618F48D7500950702 /* AsyncTask.h in Headers */,
14DD78BA18F48D6B00950702 /* Page.h in Headers */,
14DD78BB18F48D6B00950702 /* SmallChunk.h in Headers */,
14DD78C918F48D7500950702 /* Inline.h in Headers */,
14895D921A3A319C0006235D /* Environment.h in Headers */,
Expand Down
86 changes: 0 additions & 86 deletions Source/bmalloc/bmalloc/Chunk.h

This file was deleted.

14 changes: 7 additions & 7 deletions Source/bmalloc/bmalloc/Heap.cpp
Expand Up @@ -27,10 +27,10 @@
#include "BumpAllocator.h"
#include "LargeChunk.h"
#include "LargeObject.h"
#include "Line.h"
#include "Page.h"
#include "PerProcess.h"
#include "SmallChunk.h"
#include "SmallLine.h"
#include "SmallPage.h"
#include <thread>

namespace bmalloc {
Expand All @@ -54,12 +54,12 @@ void Heap::initializeLineMetadata()
size_t object = 0;
size_t line = 0;
while (object < vmPageSize) {
line = object / SmallPage::lineSize;
size_t leftover = object % SmallPage::lineSize;
line = object / smallLineSize;
size_t leftover = object % smallLineSize;

size_t objectCount;
size_t remainder;
divideRoundingUp(SmallPage::lineSize - leftover, size, objectCount, remainder);
divideRoundingUp(smallLineSize - leftover, size, objectCount, remainder);

metadata[line] = { static_cast<unsigned short>(leftover), static_cast<unsigned short>(objectCount) };

Expand Down Expand Up @@ -114,7 +114,7 @@ void Heap::allocateSmallBumpRanges(std::lock_guard<StaticMutex>& lock, size_t si
BASSERT(page->hasFreeLines(lock));

// Find a free line.
for (size_t lineNumber = 0; lineNumber < SmallPage::lineCount; ++lineNumber) {
for (size_t lineNumber = 0; lineNumber < smallLineCount; ++lineNumber) {
if (lines[lineNumber].refCount(lock))
continue;

Expand All @@ -134,7 +134,7 @@ void Heap::allocateSmallBumpRanges(std::lock_guard<StaticMutex>& lock, size_t si
page->ref(lock);

// Merge with subsequent free lines.
while (++lineNumber < SmallPage::lineCount) {
while (++lineNumber < smallLineCount) {
if (lines[lineNumber].refCount(lock))
break;

Expand Down
2 changes: 1 addition & 1 deletion Source/bmalloc/bmalloc/Heap.h
Expand Up @@ -86,7 +86,7 @@ class Heap {
void scavengeSmallPages(std::unique_lock<StaticMutex>&, std::chrono::milliseconds);
void scavengeLargeObjects(std::unique_lock<StaticMutex>&, std::chrono::milliseconds);

std::array<std::array<LineMetadata, SmallPage::lineCount>, smallMax / alignment> m_smallLineMetadata;
std::array<std::array<LineMetadata, smallLineCount>, smallMax / alignment> m_smallLineMetadata;

std::array<Vector<SmallPage*>, smallMax / alignment> m_smallPagesWithFreeLines;

Expand Down
102 changes: 0 additions & 102 deletions Source/bmalloc/bmalloc/Line.h

This file was deleted.

0 comments on commit 1e5abb6

Please sign in to comment.