Changeset 74357 in webkit


Ignore:
Timestamp:
Dec 20, 2010 12:09:25 PM (13 years ago)
Author:
ggaren@apple.com
Message:

2010-12-17 Geoffrey Garen <ggaren@apple.com>

Reviewed by Sam Weinig.

Factored common page set management into a new PageBlock base class
https://bugs.webkit.org/show_bug.cgi?id=51285

  • Android.mk:
  • CMakeLists.txt:
  • GNUmakefile.am:
  • JavaScriptCore.gypi:
  • JavaScriptCore.vcproj/WTF/WTF.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • interpreter/RegisterFile.h: (JSC::RegisterFile::RegisterFile):
  • jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize):
  • wtf/PageAllocation.cpp: Removed.
  • wtf/PageAllocation.h: (WTF::PageAllocation::deallocate): (WTF::PageAllocation::PageAllocation):
  • wtf/PageReservation.h: (WTF::PageReservation::commit): (WTF::PageReservation::decommit): (WTF::PageReservation::deallocate): (WTF::PageReservation::PageReservation):
  • wtf/wtf.pri:

2010-12-20 Geoffrey Garen <ggaren@apple.com>

Reviewed by Sam Weinig.

Factored common page set management into a new PageBlock base class
https://bugs.webkit.org/show_bug.cgi?id=51285

  • ForwardingHeaders/wtf/PageBlock.h: Added.

2010-12-20 Geoffrey Garen <ggaren@apple.com>

Reviewed by Sam Weinig.

Factored common page set management into a new PageBlock base class
https://bugs.webkit.org/show_bug.cgi?id=51285

  • ForwardingHeaders/wtf/PageBlock.h: Added.
Location:
trunk
Files:
4 added
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/Android.mk

    r70318 r74357  
    163163        wtf/HashTable.cpp \
    164164        wtf/MainThread.cpp \
    165         jit/PageAllocation.cpp\
     165        wtf/PageBlock.cpp\
    166166        wtf/RandomNumber.cpp \
    167167        wtf/RefCountedLeakCounter.cpp \
  • trunk/JavaScriptCore/CMakeLists.txt

    r69516 r74357  
    172172
    173173    wtf/DateMath.cpp
    174     wtf/PageAllocation.cpp
     174    wtf/PageBlock.cpp
    175175)
    176176SET(JavaScriptCore_HEADERS )
  • trunk/JavaScriptCore/ChangeLog

    r74309 r74357  
     12010-12-17  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Factored common page set management into a new PageBlock base class
     6        https://bugs.webkit.org/show_bug.cgi?id=51285
     7
     8        * Android.mk:
     9        * CMakeLists.txt:
     10        * GNUmakefile.am:
     11        * JavaScriptCore.gypi:
     12        * JavaScriptCore.vcproj/WTF/WTF.vcproj:
     13        * JavaScriptCore.xcodeproj/project.pbxproj:
     14        * interpreter/RegisterFile.h:
     15        (JSC::RegisterFile::RegisterFile):
     16        * jit/ExecutableAllocator.cpp:
     17        (JSC::ExecutableAllocator::intializePageSize):
     18        * wtf/PageAllocation.cpp: Removed.
     19        * wtf/PageAllocation.h:
     20        (WTF::PageAllocation::deallocate):
     21        (WTF::PageAllocation::PageAllocation):
     22        * wtf/PageReservation.h:
     23        (WTF::PageReservation::commit):
     24        (WTF::PageReservation::decommit):
     25        (WTF::PageReservation::deallocate):
     26        (WTF::PageReservation::PageReservation):
     27        * wtf/wtf.pri:
     28
    1292010-12-17  Michael Saboff  <msaboff@apple.com>
    230
  • trunk/JavaScriptCore/GNUmakefile.am

    r73109 r74357  
    476476        JavaScriptCore/wtf/OwnPtrCommon.h \
    477477        JavaScriptCore/wtf/OwnPtr.h \
    478         JavaScriptCore/wtf/PageAllocation.cpp \
    479478        JavaScriptCore/wtf/PageAllocation.h \
    480479        JavaScriptCore/wtf/PageReservation.h \
     480        JavaScriptCore/wtf/PageBlock.cpp \
    481481        JavaScriptCore/wtf/PassOwnArrayPtr.h \
    482482        JavaScriptCore/wtf/PassOwnPtr.h \
  • trunk/JavaScriptCore/JavaScriptCore.gypi

    r73105 r74357  
    407407            'wtf/OwnPtr.h',
    408408            'wtf/OwnPtrCommon.h',
    409             'wtf/PageAllocation.cpp',
     409            'wtf/PageBlock.cpp',
    410410            'wtf/PageAllocation.h',
    411411            'wtf/PageReservation',
  • trunk/JavaScriptCore/JavaScriptCore.vcproj/WTF/WTF.vcproj

    r73091 r74357  
    698698                </File>
    699699                <File
    700                         RelativePath="..\..\wtf\PageAllocation.cpp"
     700                        RelativePath="..\..\wtf\PageBlock.cpp"
    701701                        >
    702702                </File>
  • trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r73568 r74357  
    162162                14A42E400F4F60EE00599099 /* TimeoutChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 14A42E3E0F4F60EE00599099 /* TimeoutChecker.h */; settings = {ATTRIBUTES = (Private, ); }; };
    163163                14ABDF600A437FEF00ECCA01 /* JSCallbackObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14ABDF5E0A437FEF00ECCA01 /* JSCallbackObject.cpp */; };
     164                14B3EF0512BC24DD00D29EFF /* PageBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 14B3EF0312BC24DD00D29EFF /* PageBlock.h */; settings = {ATTRIBUTES = (Private, ); }; };
     165                14B3EF0612BC24DD00D29EFF /* PageBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14B3EF0412BC24DD00D29EFF /* PageBlock.cpp */; };
    164166                14B8EC720A5652090062BE54 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6560A4CF04B3B3E7008AE952 /* CoreFoundation.framework */; };
    165167                14BD59C50A3E8F9F00BAF59C /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 932F5BD90822A1C700736975 /* JavaScriptCore.framework */; };
     
    206208                860161E60F3A83C100F84710 /* MacroAssemblerX86Common.h in Headers */ = {isa = PBXBuildFile; fileRef = 860161E20F3A83C100F84710 /* MacroAssemblerX86Common.h */; };
    207209                8626BECF11928E3900782FAB /* StringStatics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8626BECE11928E3900782FAB /* StringStatics.cpp */; };
    208                 8627E5EB11F1281900A313B5 /* PageAllocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8627E5E911F1281900A313B5 /* PageAllocation.cpp */; };
    209210                8627E5EC11F1281900A313B5 /* PageAllocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 8627E5EA11F1281900A313B5 /* PageAllocation.h */; settings = {ATTRIBUTES = (Private, ); }; };
    210211                862AF4B612239C7B0024E5B8 /* DecimalNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = 862AF4B512239C7B0024E5B8 /* DecimalNumber.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    719720                14ABDF5D0A437FEF00ECCA01 /* JSCallbackObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallbackObject.h; sourceTree = "<group>"; };
    720721                14ABDF5E0A437FEF00ECCA01 /* JSCallbackObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCallbackObject.cpp; sourceTree = "<group>"; };
     722                14B3EF0312BC24DD00D29EFF /* PageBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageBlock.h; sourceTree = "<group>"; };
     723                14B3EF0412BC24DD00D29EFF /* PageBlock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageBlock.cpp; sourceTree = "<group>"; };
    721724                14B8ECA60A5653980062BE54 /* JavaScriptCore.exp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.exports; path = JavaScriptCore.exp; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
    722725                14BD59BF0A3E8F9000BAF59C /* testapi */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testapi; sourceTree = BUILT_PRODUCTS_DIR; };
     
    819822                860161E20F3A83C100F84710 /* MacroAssemblerX86Common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerX86Common.h; sourceTree = "<group>"; };
    820823                8626BECE11928E3900782FAB /* StringStatics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringStatics.cpp; path = text/StringStatics.cpp; sourceTree = "<group>"; };
    821                 8627E5E911F1281900A313B5 /* PageAllocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageAllocation.cpp; sourceTree = "<group>"; };
    822824                8627E5EA11F1281900A313B5 /* PageAllocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageAllocation.h; sourceTree = "<group>"; };
    823825                862AF4B512239C7B0024E5B8 /* DecimalNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DecimalNumber.h; sourceTree = "<group>"; };
     
    15301532                                C0A2723F0E509F1E00E96E15 /* NotFound.h */,
    15311533                                933F5CDB126922690049191E /* NullPtr.h */,
     1534                                1400067612A6F7830064D123 /* OSAllocator.h */,
    15321535                                1400069212A6F9E10064D123 /* OSAllocatorPosix.cpp */,
    1533                                 1400067612A6F7830064D123 /* OSAllocator.h */,
    15341536                                9303F5A409911A5800AD71B8 /* OwnArrayPtr.h */,
    15351537                                BCFBE697122561D200309E9D /* OwnArrayPtrCommon.h */,
     
    15371539                                9303F567099118FA00AD71B8 /* OwnPtr.h */,
    15381540                                440B7AED0FAF7FCB0073323E /* OwnPtrCommon.h */,
    1539                                 8627E5E911F1281900A313B5 /* PageAllocation.cpp */,
    15401541                                8627E5EA11F1281900A313B5 /* PageAllocation.h */,
     1542                                14B3EF0412BC24DD00D29EFF /* PageBlock.cpp */,
     1543                                14B3EF0312BC24DD00D29EFF /* PageBlock.h */,
    15411544                                8690231412092D5C00630AF9 /* PageReservation.h */,
    15421545                                BCFBE695122560E800309E9D /* PassOwnArrayPtr.h */,
     
    23652368                                F3BD31ED126735770065467F /* TextPosition.h in Headers */,
    23662369                                1400067712A6F7830064D123 /* OSAllocator.h in Headers */,
     2370                                14B3EF0512BC24DD00D29EFF /* PageBlock.h in Headers */,
    23672371                        );
    23682372                        runOnlyForDeploymentPostprocessing = 0;
     
    28142818                                86D08D5311793613006E5ED0 /* WTFThreadData.cpp in Sources */,
    28152819                                DDF7ABD511F60ED200108E36 /* GCActivityCallbackCF.cpp in Sources */,
    2816                                 8627E5EB11F1281900A313B5 /* PageAllocation.cpp in Sources */,
    28172820                                DDE82AD71209D955005C1756 /* GCHandle.cpp in Sources */,
    28182821                                A74DE1D0120B875600D40D5B /* ARMv7Assembler.cpp in Sources */,
     
    28242827                                0F29479C126E698C00B3ABF5 /* DecimalNumber.cpp in Sources */,
    28252828                                1400069312A6F9E10064D123 /* OSAllocatorPosix.cpp in Sources */,
     2829                                14B3EF0612BC24DD00D29EFF /* PageBlock.cpp in Sources */,
    28262830                        );
    28272831                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/JavaScriptCore/interpreter/RegisterFile.h

    r73570 r74357  
    160160        , m_max(0)
    161161    {
    162         ASSERT(maxGlobals && PageAllocation::isPageAligned(maxGlobals));
    163         ASSERT(capacity && PageAllocation::isPageAligned(capacity));
     162        ASSERT(maxGlobals && isPageAligned(maxGlobals));
     163        ASSERT(capacity && isPageAligned(capacity));
    164164
    165165        size_t bufferLength = (capacity + maxGlobals) * sizeof(Register);
  • trunk/JavaScriptCore/jit/ExecutableAllocator.cpp

    r73571 r74357  
    4646    ExecutableAllocator::pageSize = 256 * 1024;
    4747#else
    48     ExecutableAllocator::pageSize = PageAllocation::pageSize();
     48    ExecutableAllocator::pageSize = WTF::pageSize();
    4949#endif
    5050}
  • trunk/JavaScriptCore/wtf/PageAllocation.h

    r74297 r74357  
    2929#include <wtf/Assertions.h>
    3030#include <wtf/OSAllocator.h>
     31#include <wtf/PageBlock.h>
    3132#include <wtf/UnusedParam.h>
    3233#include <wtf/VMTags.h>
     
    8283    size is a power of two that is >= system page size.
    8384*/
    84 class PageAllocation {
     85
     86class PageAllocation : private PageBlock {
    8587public:
    86     PageAllocation()
    87         : m_base(0)
    88         , m_size(0)
    89     {
    90     }
    91 
    92     bool operator!() const { return !m_base; }
    93     void* base() const { return m_base; }
    94     size_t size() const { return m_size; }
    95 
    9688    static PageAllocation allocate(size_t size, OSAllocator::Usage usage = OSAllocator::UnknownUsage, bool writable = true, bool executable = false)
    9789    {
     
    109101#endif
    110102
     103    PageAllocation();
     104
     105    using PageBlock::operator bool;
     106    using PageBlock::base;
     107    using PageBlock::size;
     108
    111109    void deallocate()
    112110    {
    113         ASSERT(m_base);
    114         void* tmp = 0;
    115         std::swap(tmp, m_base);
    116         OSAllocator::release(tmp, m_size);
    117     }
    118 
    119     static size_t pageSize()
    120     {
    121         if (!s_pageSize)
    122             s_pageSize = systemPageSize();
    123         ASSERT(isPowerOfTwo(s_pageSize));
    124         return s_pageSize;
    125     }
    126 
    127 #ifndef NDEBUG
    128     static bool isPageAligned(void* address) { return !(reinterpret_cast<intptr_t>(address) & (pageSize() - 1)); }
    129     static bool isPageAligned(size_t size) { return !(size & (pageSize() - 1)); }
    130     static bool isPowerOfTwo(size_t size) { return !(size & (size - 1)); }
    131 #endif
    132 
    133 protected:
     111        ASSERT(*this);
     112        PageAllocation tmp;
     113        std::swap(tmp, *this);
     114        OSAllocator::release(tmp.base(), tmp.size());
     115    }
     116
     117private:
    134118    PageAllocation(void* base, size_t size)
    135         : m_base(base)
    136         , m_size(size)
     119        : PageBlock(base, size)
    137120    {
    138121    }
     
    141124    static PageAllocation systemAllocateAligned(size_t, OSAllocator::Usage);
    142125#endif
    143     static size_t systemPageSize();
    144 
    145     void* m_base;
    146     size_t m_size;
    147 
    148     static JS_EXPORTDATA size_t s_pageSize;
    149126};
    150127
     128inline PageAllocation::PageAllocation()
     129    : PageBlock()
     130{
     131}
     132
    151133
    152134#if HAVE(MMAP)
    153 
    154135
    155136inline PageAllocation PageAllocation::systemAllocateAligned(size_t size, OSAllocator::Usage usage)
     
    196177}
    197178
    198 inline size_t PageAllocation::systemPageSize()
    199 {
    200     return getpagesize();
    201 }
    202 
    203 
    204179#elif HAVE(VIRTUALALLOC)
    205 
    206180
    207181#if HAVE(ALIGNED_MALLOC)
     
    218192#endif
    219193
    220 inline size_t PageAllocation::systemPageSize()
    221 {
    222     static size_t size = 0;
    223     SYSTEM_INFO system_info;
    224     GetSystemInfo(&system_info);
    225     size = system_info.dwPageSize;
    226     return size;
    227 }
    228 
    229 
    230 #elif OS(SYMBIAN)
    231 
    232 
    233 inline size_t PageAllocation::systemPageSize()
    234 {
    235     static TInt page_size = 0;
    236     UserHal::PageSizeInBytes(page_size);
    237     return page_size;
    238 }
    239 
    240 
    241 #endif
    242 
     194#endif
    243195
    244196}
  • trunk/JavaScriptCore/wtf/PageReservation.h

    r74297 r74357  
    5454    protection before decommit is called.
    5555*/
    56 class PageReservation : private PageAllocation {
     56
     57class PageReservation : private PageBlock {
    5758public:
    5859    PageReservation()
    5960    {
    6061    }
    61 
    62     using PageAllocation::operator!;
    63     using PageAllocation::base;
    64     using PageAllocation::size;
     62   
     63    using PageBlock::operator bool;
     64    using PageBlock::base;
     65    using PageBlock::size;
    6566
    6667    void commit(void* start, size_t size)
    6768    {
    68         ASSERT(m_base);
     69        ASSERT(*this);
    6970        ASSERT(isPageAligned(start));
    7071        ASSERT(isPageAligned(size));
     
    7879    void decommit(void* start, size_t size)
    7980    {
    80         ASSERT(m_base);
     81        ASSERT(*this);
    8182        ASSERT(isPageAligned(start));
    8283        ASSERT(isPageAligned(size));
     
    9798    {
    9899        ASSERT(!m_committed);
    99         PageAllocation::deallocate();
     100        ASSERT(*this);
     101        PageReservation tmp;
     102        std::swap(tmp, *this);
     103        OSAllocator::release(tmp.base(), tmp.size());
    100104    }
    101105
    102106private:
    103107    PageReservation(void* base, size_t size, bool writable, bool executable)
    104         : PageAllocation(base, size)
     108        : PageBlock(base, size)
    105109#ifndef NDEBUG
    106110        , m_committed(0)
  • trunk/JavaScriptCore/wtf/wtf.pri

    r73842 r74357  
    1717    wtf/qt/StringQt.cpp \
    1818    wtf/qt/ThreadingQt.cpp \
    19     wtf/PageAllocation.cpp \
     19    wtf/PageBlock.cpp \
    2020    wtf/RandomNumber.cpp \
    2121    wtf/RefCountedLeakCounter.cpp \
  • trunk/JavaScriptGlue/ChangeLog

    r73094 r74357  
     12010-12-20  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Factored common page set management into a new PageBlock base class
     6        https://bugs.webkit.org/show_bug.cgi?id=51285
     7
     8        * ForwardingHeaders/wtf/PageBlock.h: Added.
     9
    1102010-12-01  Geoffrey Garen  <ggaren@apple.com>
    211
  • trunk/WebCore/ChangeLog

    r74354 r74357  
     12010-12-20  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Factored common page set management into a new PageBlock base class
     6        https://bugs.webkit.org/show_bug.cgi?id=51285
     7
     8        * ForwardingHeaders/wtf/PageBlock.h: Added.
     9
    1102010-12-20  Steve Block  <steveblock@google.com>
    211
Note: See TracChangeset for help on using the changeset viewer.