Changeset 256088 in webkit


Ignore:
Timestamp:
Feb 8, 2020 2:35:40 AM (4 years ago)
Author:
basuke.suzuki@sony.com
Message:

[bmalloc] VMHeap can be merge into Heap
https://bugs.webkit.org/show_bug.cgi?id=207410

Reviewed by Yusuke Suzuki.

VMHeap has only one member function in it and Heap is the only client of that.
No member variable is defined. It does nothing special with its context as a class.
It is safe to merge the function into Heap.

  • CMakeLists.txt:
  • bmalloc.xcodeproj/project.pbxproj:
  • bmalloc/Heap.cpp:

(bmalloc::Heap::allocateLarge):
(bmalloc::Heap::tryAllocateLargeChunk): Moved from VMHeap.

  • bmalloc/Heap.h:
  • bmalloc/VMHeap.cpp: Removed.
  • bmalloc/VMHeap.h: Removed.
Location:
trunk/Source/bmalloc
Files:
2 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/bmalloc/CMakeLists.txt

    r255829 r256088  
    3232    bmalloc/PerProcess.cpp
    3333    bmalloc/Scavenger.cpp
    34     bmalloc/VMHeap.cpp
    3534    bmalloc/bmalloc.cpp
    3635)
     
    128127    bmalloc/Syscall.h
    129128    bmalloc/VMAllocate.h
    130     bmalloc/VMHeap.h
    131129    bmalloc/Vector.h
    132130    bmalloc/Zone.h
  • trunk/Source/bmalloc/ChangeLog

    r255829 r256088  
     12020-02-08  Basuke Suzuki  <basuke.suzuki@sony.com>
     2
     3        [bmalloc] VMHeap can be merge into Heap
     4        https://bugs.webkit.org/show_bug.cgi?id=207410
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        VMHeap has only one member function in it and Heap is the only client of that.
     9        No member variable is defined. It does nothing special with its context as a class.
     10        It is safe to merge the function into Heap.
     11
     12        * CMakeLists.txt:
     13        * bmalloc.xcodeproj/project.pbxproj:
     14        * bmalloc/Heap.cpp:
     15        (bmalloc::Heap::allocateLarge):
     16        (bmalloc::Heap::tryAllocateLargeChunk): Moved from VMHeap.
     17        * bmalloc/Heap.h:
     18        * bmalloc/VMHeap.cpp: Removed.
     19        * bmalloc/VMHeap.h: Removed.
     20
    1212020-02-05  Don Olmstead  <don.olmstead@sony.com>
    222
  • trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj

    r254708 r256088  
    7979                0FD557331F7EDB7B00B1F0A3 /* HeapKind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FD557321F7EDB7B00B1F0A3 /* HeapKind.cpp */; };
    8080                1400274918F89C1300115C97 /* Heap.h in Headers */ = {isa = PBXBuildFile; fileRef = 14DA320C18875B09007269E0 /* Heap.h */; settings = {ATTRIBUTES = (Private, ); }; };
    81                 1400274A18F89C2300115C97 /* VMHeap.h in Headers */ = {isa = PBXBuildFile; fileRef = 144F7BFC18BFC517003537F3 /* VMHeap.h */; settings = {ATTRIBUTES = (Private, ); }; };
    8281                140FA00319CE429C00FFD3C8 /* BumpRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 140FA00219CE429C00FFD3C8 /* BumpRange.h */; settings = {ATTRIBUTES = (Private, ); }; };
    8382                140FA00519CE4B6800FFD3C8 /* LineMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 140FA00419CE4B6800FFD3C8 /* LineMetadata.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    126125                14F271C718EA3990008C152F /* Heap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14DA320E18875D9F007269E0 /* Heap.cpp */; };
    127126                14F271C818EA3990008C152F /* ObjectType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14105E8318E14374003A106E /* ObjectType.cpp */; };
    128                 14F271C918EA3990008C152F /* VMHeap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 144F7BFB18BFC517003537F3 /* VMHeap.cpp */; };
    129127                4426E2801C838EE0008EB042 /* Logging.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4426E27E1C838EE0008EB042 /* Logging.cpp */; };
    130128                4426E2811C838EE0008EB042 /* Logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 4426E27F1C838EE0008EB042 /* Logging.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    254252                144C07F21C7B70260051BB6A /* LargeMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LargeMap.cpp; path = bmalloc/LargeMap.cpp; sourceTree = "<group>"; };
    255253                144C07F31C7B70260051BB6A /* LargeMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LargeMap.h; path = bmalloc/LargeMap.h; sourceTree = "<group>"; };
    256                 144F7BFB18BFC517003537F3 /* VMHeap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VMHeap.cpp; path = bmalloc/VMHeap.cpp; sourceTree = "<group>"; };
    257                 144F7BFC18BFC517003537F3 /* VMHeap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VMHeap.h; path = bmalloc/VMHeap.h; sourceTree = "<group>"; };
    258254                1452478618BC757C00F80098 /* SmallLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SmallLine.h; path = bmalloc/SmallLine.h; sourceTree = "<group>"; };
    259255                145F6855179DC8CA00D65598 /* Allocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = Allocator.cpp; path = bmalloc/Allocator.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
     
    501497                                0F5BF1511F22E1570029D91D /* Scavenger.h */,
    502498                                145F6874179DF84100D65598 /* Sizes.h */,
    503                                 144F7BFB18BFC517003537F3 /* VMHeap.cpp */,
    504                                 144F7BFC18BFC517003537F3 /* VMHeap.h */,
    505499                                1440AFCC1A9527AF00837FAA /* Zone.cpp */,
    506500                                1440AFCA1A95261100837FAA /* Zone.h */,
     
    669663                                14DD78CF18F48D7500950702 /* Vector.h in Headers */,
    670664                                14DD78D018F48D7500950702 /* VMAllocate.h in Headers */,
    671                                 1400274A18F89C2300115C97 /* VMHeap.h in Headers */,
    672665                                1440AFCB1A95261100837FAA /* Zone.h in Headers */,
    673666                        );
     
    787780                                AD14AD2A202529C700890E3B /* ProcessCheck.mm in Sources */,
    788781                                0F5BF1521F22E1570029D91D /* Scavenger.cpp in Sources */,
    789                                 14F271C918EA3990008C152F /* VMHeap.cpp in Sources */,
    790782                                1440AFCD1A9527AF00837FAA /* Zone.cpp in Sources */,
    791783                        );
  • trunk/Source/bmalloc/bmalloc/Heap.cpp

    r254781 r256088  
    3939#include "SmallLine.h"
    4040#include "SmallPage.h"
    41 #include "VMHeap.h"
    4241#include "bmalloc.h"
    4342#include <thread>
    4443#include <vector>
     44
     45#if BOS(DARWIN)
     46#include "Zone.h"
     47#endif
    4548
    4649namespace bmalloc {
     
    575578        ASSERT_OR_RETURN_ON_FAILURE(!usingGigacage());
    576579
    577         range = VMHeap::get()->tryAllocateLargeChunk(alignment, size);
     580        range = tryAllocateLargeChunk(alignment, size);
    578581        ASSERT_OR_RETURN_ON_FAILURE(range);
    579582       
     
    594597}
    595598
     599LargeRange Heap::tryAllocateLargeChunk(size_t alignment, size_t size)
     600{
     601    // We allocate VM in aligned multiples to increase the chances that
     602    // the OS will provide contiguous ranges that we can merge.
     603    size_t roundedAlignment = roundUpToMultipleOf<chunkSize>(alignment);
     604    if (roundedAlignment < alignment) // Check for overflow
     605        return LargeRange();
     606    alignment = roundedAlignment;
     607
     608    size_t roundedSize = roundUpToMultipleOf<chunkSize>(size);
     609    if (roundedSize < size) // Check for overflow
     610        return LargeRange();
     611    size = roundedSize;
     612
     613    void* memory = tryVMAllocate(alignment, size);
     614    if (!memory)
     615        return LargeRange();
     616   
     617#if BOS(DARWIN)
     618    PerProcess<Zone>::get()->addRange(Range(memory, size));
     619#endif
     620
     621    return LargeRange(memory, size, 0, 0);
     622}
     623
    596624bool Heap::isLarge(UniqueLockHolder&, void* object)
    597625{
  • trunk/Source/bmalloc/bmalloc/Heap.h

    r254781 r256088  
    4848namespace bmalloc {
    4949
    50 class BeginTag;
    5150class BulkDecommit;
    5251class BumpAllocator;
    5352class DebugHeap;
    54 class EndTag;
    5553class HeapConstants;
    5654class Scavenger;
     
    122120    void deallocateSmallChunk(Chunk*, size_t pageClass);
    123121
    124     void mergeLarge(BeginTag*&, EndTag*&, Range&);
    125     void mergeLargeLeft(EndTag*&, BeginTag*&, Range&, bool& inVMHeap);
    126     void mergeLargeRight(EndTag*&, BeginTag*&, Range&, bool& inVMHeap);
    127 
     122    LargeRange tryAllocateLargeChunk(size_t alignment, size_t);
    128123    LargeRange splitAndAllocate(UniqueLockHolder&, LargeRange&, size_t alignment, size_t);
    129124
Note: See TracChangeset for help on using the changeset viewer.