⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 197068 in webkit


Ignore:
Timestamp:
Feb 25, 2016, 1:15:29 AM (11 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r196847 - 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.

Unreviewed. Fix debug build error since r196847

Fix gcc build warning appeared as below
by removing BASSERT(refCount <= maxRefCount).
error: comparison is always true due to limited range of data type
[-Werror=type-limits]

  • bmalloc/SmallLine.h:

(bmalloc::SmallLine::ref): Deleted.

Location:
releases/WebKitGTK/webkit-2.12/Source/bmalloc
Files:
4 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.12/Source/bmalloc/ChangeLog

    r197067 r197068  
     12016-02-19  Joonghun Park  <jh718.park@samsung.com>
     2
     3        Unreviewed. Fix debug build error since r196847
     4
     5        Fix gcc build warning appeared as below
     6        by removing BASSERT(refCount <= maxRefCount).
     7        error: comparison is always true due to limited range of data type
     8        [-Werror=type-limits]
     9
     10        * bmalloc/SmallLine.h:
     11        (bmalloc::SmallLine::ref): Deleted.
     12
     132016-02-19  Geoffrey Garen  <ggaren@apple.com>
     14
     15        bmalloc: Chunk, Page, and Line don't need to be class templates
     16        https://bugs.webkit.org/show_bug.cgi?id=154480
     17
     18        Reviewed by Gavin Barraclough.
     19
     20        We needed class templates to distinguish between small and medium,
     21        but medium is gone now.
     22
     23        * bmalloc.xcodeproj/project.pbxproj:
     24        * bmalloc/Chunk.h: Removed.
     25        * bmalloc/Heap.cpp:
     26        (bmalloc::Heap::initializeLineMetadata):
     27        (bmalloc::Heap::allocateSmallBumpRanges):
     28        * bmalloc/Heap.h:
     29        * bmalloc/Line.h: Removed.
     30        * bmalloc/Page.h: Removed.
     31        * bmalloc/Sizes.h:
     32        * bmalloc/SmallChunk.h: Replaced with Source/bmalloc/bmalloc/Chunk.h.
     33        (bmalloc::SmallChunk::begin):
     34        (bmalloc::SmallChunk::end):
     35        (bmalloc::SmallChunk::lines):
     36        (bmalloc::SmallChunk::pages):
     37        (bmalloc::SmallChunk::get):
     38        (bmalloc::SmallLine::get):
     39        (bmalloc::SmallLine::begin):
     40        (bmalloc::SmallLine::end):
     41        (bmalloc::SmallPage::get):
     42        (bmalloc::SmallPage::begin):
     43        (bmalloc::SmallPage::end):
     44        (bmalloc::Chunk::begin): Deleted.
     45        (bmalloc::Chunk::end): Deleted.
     46        (bmalloc::Chunk::lines): Deleted.
     47        (bmalloc::Chunk::pages): Deleted.
     48        * bmalloc/SmallLine.h: Replaced with Source/bmalloc/bmalloc/Line.h.
     49        (bmalloc::SmallLine::ref):
     50        (bmalloc::SmallLine::deref):
     51        (bmalloc::Line<Traits>::begin): Deleted.
     52        (bmalloc::Line<Traits>::end): Deleted.
     53        (bmalloc::Line<Traits>::ref): Deleted.
     54        (bmalloc::Line<Traits>::deref): Deleted.
     55        * bmalloc/SmallPage.h: Replaced with Source/bmalloc/bmalloc/Page.h.
     56        (bmalloc::SmallPage::hasFreeLines):
     57        (bmalloc::SmallPage::setHasFreeLines):
     58        (bmalloc::SmallPage::ref):
     59        (bmalloc::SmallPage::deref):
     60        (bmalloc::Page::hasFreeLines): Deleted.
     61        (bmalloc::Page::setHasFreeLines): Deleted.
     62        (bmalloc::Page<Traits>::ref): Deleted.
     63        (bmalloc::Page<Traits>::deref): Deleted.
     64        * bmalloc/SmallTraits.h: Removed.
     65
    1662016-02-18  Geoffrey Garen  <ggaren@apple.com>
    267
  • releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj

    r197067 r197068  
    3838                14DD789A18F48D4A00950702 /* Deallocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 145F685A179DC90200D65598 /* Deallocator.h */; settings = {ATTRIBUTES = (Private, ); }; };
    3939                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, ); }; };
    4340                14DD78BB18F48D6B00950702 /* SmallChunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 147AAA8C18CD36A7002201E4 /* SmallChunk.h */; settings = {ATTRIBUTES = (Private, ); }; };
    4441                14DD78BC18F48D6B00950702 /* SmallLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1452478618BC757C00F80098 /* SmallLine.h */; settings = {ATTRIBUTES = (Private, ); }; };
    4542                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, ); }; };
    4743                14DD78C518F48D7500950702 /* Algorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 1421A87718EE462A00B4DD68 /* Algorithm.h */; settings = {ATTRIBUTES = (Private, ); }; };
    4844                14DD78C618F48D7500950702 /* AsyncTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 1417F65218BA88A00076FA3F /* AsyncTask.h */; settings = {ATTRIBUTES = (Private, ); }; };
    … …  
    114110                146BEE1E18C841C50002D5A2 /* SegregatedFreeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SegregatedFreeList.h; path = bmalloc/SegregatedFreeList.h; sourceTree = "<group>"; };
    115111                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>"; };
    117112                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; };
    118113                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; };
    119114                147AAA8818CD17CE002201E4 /* LargeChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LargeChunk.h; path = bmalloc/LargeChunk.h; sourceTree = "<group>"; };
    120115                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>"; };
    123116                1485655E18A43AF900ED6942 /* BoundaryTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BoundaryTag.h; path = bmalloc/BoundaryTag.h; sourceTree = "<group>"; };
    124117                1485656018A43DBA00ED6942 /* ObjectType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectType.h; path = bmalloc/ObjectType.h; sourceTree = "<group>"; };
    … …  
    134127                14D2CD9A1AA12CFB00770440 /* VMState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VMState.h; path = bmalloc/VMState.h; sourceTree = "<group>"; };
    135128                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; };
    137129                14DA320C18875B09007269E0 /* Heap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Heap.h; path = bmalloc/Heap.h; sourceTree = "<group>"; };
    138130                14DA320E18875D9F007269E0 /* Heap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Heap.cpp; path = bmalloc/Heap.cpp; sourceTree = "<group>"; };
    … …  
    194186                        isa = PBXGroup;
    195187                        children = (
    196                                 147AAA9418CE5CA6002201E4 /* Chunk.h */,
    197                                 14DA32071885F9E6007269E0 /* Line.h */,
    198                                 146BEE2318C980D60002D5A2 /* Page.h */,
    199188                                147AAA8C18CD36A7002201E4 /* SmallChunk.h */,
    200189                                1452478618BC757C00F80098 /* SmallLine.h */,
    201190                                143E29ED18CAE90500FE8A0F /* SmallPage.h */,
    202                                 147AAA9718CE5FB6002201E4 /* SmallTraits.h */,
    203191                        );
    204192                        name = "heap: small | medium";
    … …  
    304292                        buildActionMask = 2147483647;
    305293                        files = (
    306                                 14DD78B518F48D6B00950702 /* Line.h in Headers */,
    307294                                14DD78CF18F48D7500950702 /* Vector.h in Headers */,
    308295                                14C919C918FCC59F0028DB43 /* BPlatform.h in Headers */,
    … …  
    312299                                140FA00519CE4B6800FFD3C8 /* LineMetadata.h in Headers */,
    313300                                14DD78CC18F48D7500950702 /* PerThread.h in Headers */,
    314                                 14DD78B418F48D6B00950702 /* Chunk.h in Headers */,
    315301                                14DD78CA18F48D7500950702 /* Mutex.h in Headers */,
    316302                                143CB81D19022BC900B16A45 /* StaticMutex.h in Headers */,
    … …  
    323309                                14DD789C18F48D4A00950702 /* BumpAllocator.h in Headers */,
    324310                                14DD789918F48D4A00950702 /* Cache.h in Headers */,
    325                                 14DD78BE18F48D6B00950702 /* SmallTraits.h in Headers */,
    326311                                14DD789018F48CEB00950702 /* Sizes.h in Headers */,
    327312                                14DD78C718F48D7500950702 /* BAssert.h in Headers */,
    … …  
    331316                                14DD78CE18F48D7500950702 /* Syscall.h in Headers */,
    332317                                14DD78C618F48D7500950702 /* AsyncTask.h in Headers */,
    333                                 14DD78BA18F48D6B00950702 /* Page.h in Headers */,
    334318                                14DD78BB18F48D6B00950702 /* SmallChunk.h in Headers */,
    335319                                14DD78C918F48D7500950702 /* Inline.h in Headers */,
  • releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Heap.cpp

    r197067 r197068  
    2828#include "LargeChunk.h"
    2929#include "LargeObject.h"
    30 #include "Line.h"
    31 #include "Page.h"
    3230#include "PerProcess.h"
    3331#include "SmallChunk.h"
     32#include "SmallLine.h"
     33#include "SmallPage.h"
    3434#include <thread>
    3535
    … …  
    5555        size_t line = 0;
    5656        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;
    5959
    6060            size_t objectCount;
    6161            size_t remainder;
    62             divideRoundingUp(SmallPage::lineSize - leftover, size, objectCount, remainder);
     62            divideRoundingUp(smallLineSize - leftover, size, objectCount, remainder);
    6363
    6464            metadata[line] = { static_cast<unsigned short>(leftover), static_cast<unsigned short>(objectCount) };
    … …  
    115115
    116116    // Find a free line.
    117     for (size_t lineNumber = 0; lineNumber < SmallPage::lineCount; ++lineNumber) {
     117    for (size_t lineNumber = 0; lineNumber < smallLineCount; ++lineNumber) {
    118118        if (lines[lineNumber].refCount(lock))
    119119            continue;
    … …  
    135135
    136136        // Merge with subsequent free lines.
    137         while (++lineNumber < SmallPage::lineCount) {
     137        while (++lineNumber < smallLineCount) {
    138138            if (lines[lineNumber].refCount(lock))
    139139                break;
  • releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Heap.h

    r197067 r197068  
    8787    void scavengeLargeObjects(std::unique_lock<StaticMutex>&, std::chrono::milliseconds);
    8888
    89     std::array<std::array<LineMetadata, SmallPage::lineCount>, smallMax / alignment> m_smallLineMetadata;
     89    std::array<std::array<LineMetadata, smallLineCount>, smallMax / alignment> m_smallLineMetadata;
    9090
    9191    std::array<Vector<SmallPage*>, smallMax / alignment> m_smallPagesWithFreeLines;
  • releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Sizes.h

    r197067 r197068  
    5959    static const size_t smallMax = 1024;
    6060    static const size_t smallLineSize = 256;
     61    static const size_t smallLineCount = vmPageSize / smallLineSize;
    6162    static const size_t smallLineMask = ~(smallLineSize - 1ul);
    6263
  • releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallChunk.h

    r166893 r197068  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    … …  
    2727#define SmallChunk_h
    2828
    29 #include "Chunk.h"
     29#include "Sizes.h"
    3030#include "SmallLine.h"
    3131#include "SmallPage.h"
    32 #include "SmallTraits.h"
     32#include "VMAllocate.h"
    3333
    3434namespace bmalloc {
    3535
    36 typedef Chunk<SmallTraits> SmallChunk;
     36class SmallChunk {
     37public:
     38    static SmallChunk* get(void*);
     39
     40    SmallPage* begin() { return SmallPage::get(SmallLine::get(m_memory)); }
     41    SmallPage* end() { return &m_pages[pageCount]; }
     42   
     43    SmallLine* lines() { return m_lines; }
     44    SmallPage* pages() { return m_pages; }
     45
     46private:
     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");
     49
     50    static const size_t lineCount = smallChunkSize / smallLineSize;
     51    static const size_t pageCount = smallChunkSize / vmPageSize;
     52
     53    SmallLine m_lines[lineCount];
     54    SmallPage m_pages[pageCount];
     55
     56    // Align to vmPageSize to avoid sharing physical pages with metadata.
     57    // Otherwise, we'll confuse the scavenger into trying to scavenge metadata.
     58    // FIXME: Below #ifdef workaround fix should be removed after all linux based ports bump
     59    // own gcc version. See https://bugs.webkit.org/show_bug.cgi?id=140162#c87
     60#if BPLATFORM(IOS)
     61    char m_memory[] __attribute__((aligned(16384)));
     62    static_assert(vmPageSize == 16384, "vmPageSize and alignment must be same");
     63#else
     64    char m_memory[] __attribute__((aligned(4096)));
     65    static_assert(vmPageSize == 4096, "vmPageSize and alignment must be same");
     66#endif
     67};
     68
     69inline SmallChunk* SmallChunk::get(void* object)
     70{
     71    BASSERT(isSmall(object));
     72    return static_cast<SmallChunk*>(mask(object, smallChunkMask));
     73}
     74
     75inline 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
     83inline 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
     91inline char* SmallLine::end()
     92{
     93    return begin() + smallLineSize;
     94}
     95
     96inline 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
     104inline 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
     112inline SmallLine* SmallPage::end()
     113{
     114    return begin() + smallLineCount;
     115}
    37116
    38117}; // namespace bmalloc
    39118
    40 #endif // SmallChunk
     119#endif // Chunk
  • releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallLine.h

    r166893 r197068  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    … …  
    2727#define SmallLine_h
    2828
    29 #include "Line.h"
    30 #include "SmallTraits.h"
     29#include "BAssert.h"
     30#include "Mutex.h"
     31#include "ObjectType.h"
     32#include <mutex>
    3133
    3234namespace bmalloc {
    3335
    34 typedef Line<SmallTraits> SmallLine;
     36class SmallLine {
     37public:
     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
     41    static SmallLine* get(void*);
     42
     43    void ref(std::lock_guard<StaticMutex>&, unsigned char);
     44    bool deref(std::lock_guard<StaticMutex>&);
     45    unsigned refCount(std::lock_guard<StaticMutex>&) { return m_refCount; }
     46   
     47    char* begin();
     48    char* end();
     49
     50private:
     51    unsigned char m_refCount;
     52};
     53
     54inline void SmallLine::ref(std::lock_guard<StaticMutex>&, unsigned char refCount)
     55{
     56    BASSERT(!m_refCount);
     57    m_refCount = refCount;
     58}
     59
     60inline bool SmallLine::deref(std::lock_guard<StaticMutex>&)
     61{
     62    BASSERT(m_refCount);
     63    --m_refCount;
     64    return !m_refCount;
     65}
    3566
    3667} // namespace bmalloc
  • releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallPage.h

    r166893 r197068  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    … …  
    2727#define SmallPage_h
    2828
    29 #include "SmallTraits.h"
    30 #include "Page.h"
     29#include "BAssert.h"
     30#include "Mutex.h"
     31#include "VMAllocate.h"
     32#include <mutex>
    3133
    3234namespace bmalloc {
    3335
    34 typedef Page<SmallTraits> SmallPage;
     36class SmallPage {
     37public:
     38    static const unsigned char maxRefCount = std::numeric_limits<unsigned char>::max();
     39    static_assert(smallLineCount < maxRefCount, "maximum line count must fit in SmallPage");
     40   
     41    static SmallPage* get(SmallLine*);
     42
     43    void ref(std::lock_guard<StaticMutex>&);
     44    bool deref(std::lock_guard<StaticMutex>&);
     45    unsigned refCount(std::lock_guard<StaticMutex>&) { return m_refCount; }
     46   
     47    size_t sizeClass() { return m_sizeClass; }
     48    void setSizeClass(size_t sizeClass) { m_sizeClass = sizeClass; }
     49   
     50    bool hasFreeLines(std::lock_guard<StaticMutex>&) const { return m_hasFreeLines; }
     51    void setHasFreeLines(std::lock_guard<StaticMutex>&, bool hasFreeLines) { m_hasFreeLines = hasFreeLines; }
     52   
     53    SmallLine* begin();
     54    SmallLine* end();
     55
     56private:
     57    unsigned char m_hasFreeLines: 1;
     58    unsigned char m_refCount: 7;
     59    unsigned char m_sizeClass;
     60};
     61
     62inline void SmallPage::ref(std::lock_guard<StaticMutex>&)
     63{
     64    BASSERT(m_refCount < maxRefCount);
     65    ++m_refCount;
     66}
     67
     68inline bool SmallPage::deref(std::lock_guard<StaticMutex>&)
     69{
     70    BASSERT(m_refCount);
     71    --m_refCount;
     72    return !m_refCount;
     73}
    3574
    3675} // namespace bmalloc
Note: See TracChangeset for help on using the changeset viewer.