Changeset 198198 in webkit


Ignore:
Timestamp:
Mar 14, 2016, 10:39:35 PM (9 years ago)
Author:
ggaren@apple.com
Message:

Unreviewed, rolling out r197955.

I decided to go in another direction

Reverted changeset:

"bmalloc: Rename SmallPage to SmallRun"
https://bugs.webkit.org/show_bug.cgi?id=155320
http://trac.webkit.org/changeset/197955

Location:
trunk/Source/bmalloc
Files:
1 deleted
9 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/bmalloc/ChangeLog

    r197955 r198198  
     12016-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
    1132016-03-10  Geoffrey Garen  <ggaren@apple.com>
    214
  • trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj

    r197955 r198198  
    4444                14DD78BB18F48D6B00950702 /* SmallChunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 147AAA8C18CD36A7002201E4 /* SmallChunk.h */; settings = {ATTRIBUTES = (Private, ); }; };
    4545                14DD78BC18F48D6B00950702 /* SmallLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1452478618BC757C00F80098 /* SmallLine.h */; settings = {ATTRIBUTES = (Private, ); }; };
    46                 14DD78BD18F48D6B00950702 /* SmallRun.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, ); }; };
    4747                14DD78C518F48D7500950702 /* Algorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 1421A87718EE462A00B4DD68 /* Algorithm.h */; settings = {ATTRIBUTES = (Private, ); }; };
    4848                14DD78C618F48D7500950702 /* AsyncTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 1417F65218BA88A00076FA3F /* AsyncTask.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    9292                143CB81A19022BC900B16A45 /* StaticMutex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StaticMutex.cpp; path = bmalloc/StaticMutex.cpp; sourceTree = "<group>"; };
    9393                143CB81B19022BC900B16A45 /* StaticMutex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StaticMutex.h; path = bmalloc/StaticMutex.h; sourceTree = "<group>"; };
    94                 143E29ED18CAE90500FE8A0F /* SmallRun.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>"; };
    9595                143EF9AD1A9FABF6004F5C77 /* FreeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FreeList.cpp; path = bmalloc/FreeList.cpp; sourceTree = "<group>"; };
    9696                143EF9AE1A9FABF6004F5C77 /* FreeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FreeList.h; path = bmalloc/FreeList.h; sourceTree = "<group>"; };
     
    209209                                147AAA8C18CD36A7002201E4 /* SmallChunk.h */,
    210210                                1452478618BC757C00F80098 /* SmallLine.h */,
    211                                 143E29ED18CAE90500FE8A0F /* SmallRun.h */,
     211                                143E29ED18CAE90500FE8A0F /* SmallPage.h */,
    212212                        );
    213213                        name = "heap: small";
     
    347347                                140FA00319CE429C00FFD3C8 /* BumpRange.h in Headers */,
    348348                                14DD78C518F48D7500950702 /* Algorithm.h in Headers */,
    349                                 14DD78BD18F48D6B00950702 /* SmallRun.h in Headers */,
     349                                14DD78BD18F48D6B00950702 /* SmallPage.h in Headers */,
    350350                                14DD788E18F48CCD00950702 /* BoundaryTag.h in Headers */,
    351351                                146041E71C7FF2EF00E9F94E /* SortedVector.h in Headers */,
  • trunk/Source/bmalloc/bmalloc/Allocator.cpp

    r197955 r198198  
    115115    switch (objectType(object)) {
    116116    case Small: {
    117         SmallRun* run = SmallRun::get(SmallLine::get(object));
    118         oldSize = objectSize(run->sizeClass());
     117        SmallPage* page = SmallPage::get(SmallLine::get(object));
     118        oldSize = objectSize(page->sizeClass());
    119119        break;
    120120    }
  • trunk/Source/bmalloc/bmalloc/Heap.cpp

    r197955 r198198  
    3131#include "SmallChunk.h"
    3232#include "SmallLine.h"
    33 #include "SmallRun.h"
     33#include "SmallPage.h"
    3434#include <thread>
    3535
     
    4141    , m_scavenger(*this, &Heap::concurrentScavenge)
    4242{
    43     initializeSmallRunMetadata();
    44 }
    45 
    46 void Heap::initializeSmallRunMetadata()
    47 {
    48     // We assume that m_smallRunMetadata is zero-filled.
     43    initializeLineMetadata();
     44}
     45
     46void Heap::initializeLineMetadata()
     47{
     48    // We assume that m_smallLineMetadata is zero-filled.
    4949
    5050    for (size_t size = alignment; size <= smallMax; size += alignment) {
    5151        size_t sizeClass = bmalloc::sizeClass(size);
    52         auto& metadata = m_smallRunMetadata[sizeClass];
     52        auto& metadata = m_smallLineMetadata[sizeClass];
    5353
    5454        size_t object = 0;
     
    8585    waitUntilFalse(lock, sleepDuration, m_isAllocatingPages);
    8686
    87     scavengeSmallRuns(lock, sleepDuration);
     87    scavengeSmallPages(lock, sleepDuration);
    8888    scavengeLargeObjects(lock, sleepDuration);
    8989    scavengeXLargeObjects(lock, sleepDuration);
     
    9292}
    9393
    94 void Heap::scavengeSmallRuns(std::unique_lock<StaticMutex>& lock, std::chrono::milliseconds sleepDuration)
    95 {
    96     while (!m_smallRuns.isEmpty()) {
    97         m_vmHeap.deallocateSmallRun(lock, m_smallRuns.pop());
     94void 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());
    9898        waitUntilFalse(lock, sleepDuration, m_isAllocatingPages);
    9999    }
     
    127127{
    128128    BASSERT(!rangeCache.size());
    129     SmallRun* 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));
    132132
    133133    // Find a free line.
     
    136136            continue;
    137137
    138         LineMetadata& lineMetadata = m_smallRunMetadata[sizeClass][lineNumber];
     138        LineMetadata& lineMetadata = m_smallLineMetadata[sizeClass][lineNumber];
    139139        if (!lineMetadata.objectCount)
    140140            continue;
    141141
    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.
    143143        if (rangeCache.size() == rangeCache.capacity()) {
    144             m_smallRunsWithFreeLines[sizeClass].push(run);
     144            m_smallPagesWithFreeLines[sizeClass].push(page);
    145145            BASSERT(allocator.canAllocate());
    146146            return;
     
    150150        unsigned short objectCount = lineMetadata.objectCount;
    151151        lines[lineNumber].ref(lock, lineMetadata.objectCount);
    152         run->ref(lock);
     152        page->ref(lock);
    153153
    154154        // Merge with subsequent free lines.
     
    157157                break;
    158158
    159             LineMetadata& lineMetadata = m_smallRunMetadata[sizeClass][lineNumber];
     159            LineMetadata& lineMetadata = m_smallLineMetadata[sizeClass][lineNumber];
    160160            if (!lineMetadata.objectCount)
    161161                continue;
     
    163163            objectCount += lineMetadata.objectCount;
    164164            lines[lineNumber].ref(lock, lineMetadata.objectCount);
    165             run->ref(lock);
     165            page->ref(lock);
    166166        }
    167167
     
    173173
    174174    BASSERT(allocator.canAllocate());
    175     run->setHasFreeLines(lock, false);
    176 }
    177 
    178 SmallRun* Heap::allocateSmallRun(std::lock_guard<StaticMutex>& lock, size_t sizeClass)
    179 {
    180     if (!m_smallRunsWithFreeLines[sizeClass].isEmpty())
    181         return m_smallRunsWithFreeLines[sizeClass].pop();
    182 
    183     SmallRun* run = [this, &lock]() {
    184         if (!m_smallRuns.isEmpty())
    185             return m_smallRuns.pop();
     175    page->setHasFreeLines(lock, false);
     176}
     177
     178SmallPage* 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();
    186186
    187187        m_isAllocatingPages = true;
    188         return m_vmHeap.allocateSmallRun(lock);
     188        SmallPage* page = m_vmHeap.allocateSmallPage(lock);
     189        return page;
    189190    }();
    190191
    191     run->setSizeClass(sizeClass);
    192     return run;
     192    page->setSizeClass(sizeClass);
     193    return page;
    193194}
    194195
     
    196197{
    197198    BASSERT(!line->refCount(lock));
    198     SmallRun* run = SmallRun::get(line);
    199     run->deref(lock);
    200 
    201     if (!run->hasFreeLines(lock)) {
    202         run->setHasFreeLines(lock, true);
    203         m_smallRunsWithFreeLines[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));
    206207        return;
    207208    }
    208209
    209     if (run->refCount(lock))
     210    if (page->refCount(lock))
    210211        return;
    211212
    212     m_smallRunsWithFreeLines[run->sizeClass()].remove(run);
    213     m_smallRuns.push(run);
     213    m_smallPagesWithFreeLines[page->sizeClass()].remove(page);
     214    m_smallPages.push(page);
    214215    m_scavenger.run();
    215216}
  • trunk/Source/bmalloc/bmalloc/Heap.h

    r197955 r198198  
    3535#include "SmallChunk.h"
    3636#include "SmallLine.h"
    37 #include "SmallRun.h"
     37#include "SmallPage.h"
    3838#include "VMHeap.h"
    3939#include "Vector.h"
     
    7373    ~Heap() = delete;
    7474   
    75     void initializeSmallRunMetadata();
     75    void initializeLineMetadata();
    7676
    77     SmallRun* allocateSmallRun(std::lock_guard<StaticMutex>&, size_t sizeClass);
     77    SmallPage* allocateSmallPage(std::lock_guard<StaticMutex>&, size_t sizeClass);
    7878
    7979    void deallocateSmallLine(std::lock_guard<StaticMutex>&, SmallLine*);
     
    8989
    9090    void concurrentScavenge();
    91     void scavengeSmallRuns(std::unique_lock<StaticMutex>&, std::chrono::milliseconds);
     91    void scavengeSmallPages(std::unique_lock<StaticMutex>&, std::chrono::milliseconds);
    9292    void scavengeLargeObjects(std::unique_lock<StaticMutex>&, std::chrono::milliseconds);
    9393    void scavengeXLargeObjects(std::unique_lock<StaticMutex>&, std::chrono::milliseconds);
    9494
    95     std::array<RunMetadata, smallMax / alignment> m_smallRunMetadata;
     95    std::array<std::array<LineMetadata, smallLineCount>, smallMax / alignment> m_smallLineMetadata;
    9696
    97     std::array<List<SmallRun>, smallMax / alignment> m_smallRunsWithFreeLines;
     97    std::array<List<SmallPage>, smallMax / alignment> m_smallPagesWithFreeLines;
    9898
    99     List<SmallRun> m_smallRuns;
     99    List<SmallPage> m_smallPages;
    100100
    101101    SegregatedFreeList m_largeObjects;
  • trunk/Source/bmalloc/bmalloc/LineMetadata.h

    r197955 r198198  
    3434};
    3535
    36 typedef std::array<LineMetadata, smallLineCount> RunMetadata;
    37 
    3836} // namespace bmalloc
    3937
  • trunk/Source/bmalloc/bmalloc/SmallChunk.h

    r197955 r198198  
    2929#include "Sizes.h"
    3030#include "SmallLine.h"
    31 #include "SmallRun.h"
     31#include "SmallPage.h"
    3232#include "VMAllocate.h"
    3333
     
    4040    static SmallChunk* get(void*);
    4141
    42     SmallRun* begin() { return SmallRun::get(SmallLine::get(m_memory)); }
    43     SmallRun* end() { return m_runs.end(); }
     42    SmallPage* begin() { return SmallPage::get(SmallLine::get(m_memory)); }
     43    SmallPage* end() { return m_pages.end(); }
    4444   
    4545    SmallLine* lines() { return m_lines.begin(); }
    46     SmallRun* runs() { return m_runs.begin(); }
     46    SmallPage* pages() { return m_pages.begin(); }
    4747   
    4848private:
    4949    std::array<SmallLine, smallChunkSize / smallLineSize> m_lines;
    50     std::array<SmallRun, smallChunkSize / vmPageSize> m_runs;
     50    std::array<SmallPage, smallChunkSize / vmPageSize> m_pages;
    5151    char m_memory[] __attribute__((aligned(2 * smallMax + 0)));
    5252};
     
    6464        line->ref(lock, 1);
    6565
    66         SmallRun* page = SmallRun::get(line);
     66        SmallPage* page = SmallPage::get(line);
    6767        page->ref(lock);
    6868    }
    6969
    70     for (SmallRun* page = begin(); page != end(); ++page)
     70    for (SmallPage* page = begin(); page != end(); ++page)
    7171        page->setHasFreeLines(lock, true);
    7272}
     
    9999}
    100100
    101 inline SmallRun* SmallRun::get(SmallLine* line)
     101inline SmallPage* SmallPage::get(SmallLine* line)
    102102{
    103103    SmallChunk* chunk = SmallChunk::get(line);
    104104    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];
    107107}
    108108
    109 inline SmallLine* SmallRun::begin()
     109inline SmallLine* SmallPage::begin()
    110110{
    111111    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;
    114114    return &chunk->lines()[lineNumber];
    115115}
    116116
    117 inline SmallLine* SmallRun::end()
     117inline SmallLine* SmallPage::end()
    118118{
    119119    return begin() + smallLineCount;
  • trunk/Source/bmalloc/bmalloc/VMHeap.cpp

    r197955 r198198  
    4545    SmallChunk* smallChunk = new (m_smallChunks.pop()->smallChunk()) SmallChunk(lock);
    4646    for (auto* it = smallChunk->begin(); it < smallChunk->end(); ++it)
    47         m_smallRuns.push(it);
     47        m_smallPages.push(it);
    4848}
    4949
  • trunk/Source/bmalloc/bmalloc/VMHeap.h

    r197955 r198198  
    5151    VMHeap();
    5252
    53     SmallRun* allocateSmallRun(std::lock_guard<StaticMutex>&);
     53    SmallPage* allocateSmallPage(std::lock_guard<StaticMutex>&);
    5454    LargeObject allocateLargeObject(std::lock_guard<StaticMutex>&, size_t);
    5555    LargeObject allocateLargeObject(std::lock_guard<StaticMutex>&, size_t, size_t, size_t);
    5656
    57     void deallocateSmallRun(std::unique_lock<StaticMutex>&, SmallRun*);
     57    void deallocateSmallPage(std::unique_lock<StaticMutex>&, SmallPage*);
    5858    void deallocateLargeObject(std::unique_lock<StaticMutex>&, LargeObject);
    5959   
     
    6363    void allocateSuperChunk(std::lock_guard<StaticMutex>&);
    6464
    65     List<SmallRun> m_smallRuns;
     65    List<SmallPage> m_smallPages;
    6666    SegregatedFreeList m_largeObjects;
    6767
     
    7474};
    7575
    76 inline SmallRun* VMHeap::allocateSmallRun(std::lock_guard<StaticMutex>& lock)
     76inline SmallPage* VMHeap::allocateSmallPage(std::lock_guard<StaticMutex>& lock)
    7777{
    78     if (m_smallRuns.isEmpty())
     78    if (m_smallPages.isEmpty())
    7979        allocateSmallChunk(lock);
    8080
    81     SmallRun* 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;
    8484}
    8585
     
    102102}
    103103
    104 inline void VMHeap::deallocateSmallRun(std::unique_lock<StaticMutex>& lock, SmallRun* run)
     104inline void VMHeap::deallocateSmallPage(std::unique_lock<StaticMutex>& lock, SmallPage* page)
    105105{
    106106    lock.unlock();
    107     vmDeallocatePhysicalPages(run->begin()->begin(), vmPageSize);
     107    vmDeallocatePhysicalPages(page->begin()->begin(), vmPageSize);
    108108    lock.lock();
    109109   
    110     m_smallRuns.push(run);
     110    m_smallPages.push(page);
    111111}
    112112
Note: See TracChangeset for help on using the changeset viewer.