Title: [256088] trunk/Source/bmalloc
Revision
256088
Author
[email protected]
Date
2020-02-08 02:35:40 -0800 (Sat, 08 Feb 2020)

Log 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.

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/bmalloc/CMakeLists.txt (256087 => 256088)


--- trunk/Source/bmalloc/CMakeLists.txt	2020-02-08 06:08:33 UTC (rev 256087)
+++ trunk/Source/bmalloc/CMakeLists.txt	2020-02-08 10:35:40 UTC (rev 256088)
@@ -31,7 +31,6 @@
     bmalloc/ObjectType.cpp
     bmalloc/PerProcess.cpp
     bmalloc/Scavenger.cpp
-    bmalloc/VMHeap.cpp
     bmalloc/bmalloc.cpp
 )
 
@@ -127,7 +126,6 @@
     bmalloc/StdLibExtras.h
     bmalloc/Syscall.h
     bmalloc/VMAllocate.h
-    bmalloc/VMHeap.h
     bmalloc/Vector.h
     bmalloc/Zone.h
     bmalloc/bmalloc.h

Modified: trunk/Source/bmalloc/ChangeLog (256087 => 256088)


--- trunk/Source/bmalloc/ChangeLog	2020-02-08 06:08:33 UTC (rev 256087)
+++ trunk/Source/bmalloc/ChangeLog	2020-02-08 10:35:40 UTC (rev 256088)
@@ -1,3 +1,23 @@
+2020-02-08  Basuke Suzuki  <[email protected]>
+
+        [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.
+
 2020-02-05  Don Olmstead  <[email protected]>
 
         [bmalloc] Add declspec support for export macros

Modified: trunk/Source/bmalloc/bmalloc/Heap.cpp (256087 => 256088)


--- trunk/Source/bmalloc/bmalloc/Heap.cpp	2020-02-08 06:08:33 UTC (rev 256087)
+++ trunk/Source/bmalloc/bmalloc/Heap.cpp	2020-02-08 10:35:40 UTC (rev 256088)
@@ -38,11 +38,14 @@
 #include "Scavenger.h"
 #include "SmallLine.h"
 #include "SmallPage.h"
-#include "VMHeap.h"
 #include "bmalloc.h"
 #include <thread>
 #include <vector>
 
+#if BOS(DARWIN)
+#include "Zone.h"
+#endif
+
 namespace bmalloc {
 
 Heap::Heap(HeapKind kind, LockHolder&)
@@ -574,7 +577,7 @@
 
         ASSERT_OR_RETURN_ON_FAILURE(!usingGigacage());
 
-        range = VMHeap::get()->tryAllocateLargeChunk(alignment, size);
+        range = tryAllocateLargeChunk(alignment, size);
         ASSERT_OR_RETURN_ON_FAILURE(range);
         
         m_largeFree.add(range);
@@ -593,6 +596,31 @@
 #undef ASSERT_OR_RETURN_ON_FAILURE
 }
 
+LargeRange Heap::tryAllocateLargeChunk(size_t alignment, size_t size)
+{
+    // We allocate VM in aligned multiples to increase the chances that
+    // the OS will provide contiguous ranges that we can merge.
+    size_t roundedAlignment = roundUpToMultipleOf<chunkSize>(alignment);
+    if (roundedAlignment < alignment) // Check for overflow
+        return LargeRange();
+    alignment = roundedAlignment;
+
+    size_t roundedSize = roundUpToMultipleOf<chunkSize>(size);
+    if (roundedSize < size) // Check for overflow
+        return LargeRange();
+    size = roundedSize;
+
+    void* memory = tryVMAllocate(alignment, size);
+    if (!memory)
+        return LargeRange();
+    
+#if BOS(DARWIN)
+    PerProcess<Zone>::get()->addRange(Range(memory, size));
+#endif
+
+    return LargeRange(memory, size, 0, 0);
+}
+
 bool Heap::isLarge(UniqueLockHolder&, void* object)
 {
     return m_objectTypes.get(Object(object).chunk()) == ObjectType::Large;

Modified: trunk/Source/bmalloc/bmalloc/Heap.h (256087 => 256088)


--- trunk/Source/bmalloc/bmalloc/Heap.h	2020-02-08 06:08:33 UTC (rev 256087)
+++ trunk/Source/bmalloc/bmalloc/Heap.h	2020-02-08 10:35:40 UTC (rev 256088)
@@ -47,11 +47,9 @@
 
 namespace bmalloc {
 
-class BeginTag;
 class BulkDecommit;
 class BumpAllocator;
 class DebugHeap;
-class EndTag;
 class HeapConstants;
 class Scavenger;
 
@@ -121,10 +119,7 @@
     void allocateSmallChunk(UniqueLockHolder&, size_t pageClass, FailureAction);
     void deallocateSmallChunk(Chunk*, size_t pageClass);
 
-    void mergeLarge(BeginTag*&, EndTag*&, Range&);
-    void mergeLargeLeft(EndTag*&, BeginTag*&, Range&, bool& inVMHeap);
-    void mergeLargeRight(EndTag*&, BeginTag*&, Range&, bool& inVMHeap);
-
+    LargeRange tryAllocateLargeChunk(size_t alignment, size_t);
     LargeRange splitAndAllocate(UniqueLockHolder&, LargeRange&, size_t alignment, size_t);
 
     HeapKind m_kind;

Deleted: trunk/Source/bmalloc/bmalloc/VMHeap.cpp (256087 => 256088)


--- trunk/Source/bmalloc/bmalloc/VMHeap.cpp	2020-02-08 06:08:33 UTC (rev 256087)
+++ trunk/Source/bmalloc/bmalloc/VMHeap.cpp	2020-02-08 10:35:40 UTC (rev 256088)
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#include "PerProcess.h"
-#include "VMHeap.h"
-#include <thread>
-
-namespace bmalloc {
-
-DEFINE_STATIC_PER_PROCESS_STORAGE(VMHeap);
-
-VMHeap::VMHeap(const LockHolder&)
-{
-}
-
-LargeRange VMHeap::tryAllocateLargeChunk(size_t alignment, size_t size)
-{
-    // We allocate VM in aligned multiples to increase the chances that
-    // the OS will provide contiguous ranges that we can merge.
-    size_t roundedAlignment = roundUpToMultipleOf<chunkSize>(alignment);
-    if (roundedAlignment < alignment) // Check for overflow
-        return LargeRange();
-    alignment = roundedAlignment;
-
-    size_t roundedSize = roundUpToMultipleOf<chunkSize>(size);
-    if (roundedSize < size) // Check for overflow
-        return LargeRange();
-    size = roundedSize;
-
-    void* memory = tryVMAllocate(alignment, size);
-    if (!memory)
-        return LargeRange();
-    
-    Chunk* chunk = static_cast<Chunk*>(memory);
-    
-#if BOS(DARWIN)
-    PerProcess<Zone>::get()->addRange(Range(chunk->bytes(), size));
-#endif
-
-    return LargeRange(chunk->bytes(), size, 0, 0);
-}
-
-} // namespace bmalloc

Deleted: trunk/Source/bmalloc/bmalloc/VMHeap.h (256087 => 256088)


--- trunk/Source/bmalloc/bmalloc/VMHeap.h	2020-02-08 06:08:33 UTC (rev 256087)
+++ trunk/Source/bmalloc/bmalloc/VMHeap.h	2020-02-08 10:35:40 UTC (rev 256088)
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#ifndef VMHeap_h
-#define VMHeap_h
-
-#include "Chunk.h"
-#include "FixedVector.h"
-#include "HeapKind.h"
-#include "LargeRange.h"
-#include "Map.h"
-#include "StaticPerProcess.h"
-#include "Vector.h"
-#if BOS(DARWIN)
-#include "Zone.h"
-#endif
-
-namespace bmalloc {
-
-class BeginTag;
-class EndTag;
-class Heap;
-
-typedef enum { Sync, Async } ScavengeMode;
-
-class VMHeap : public StaticPerProcess<VMHeap> {
-public:
-    VMHeap(const LockHolder&);
-    
-    LargeRange tryAllocateLargeChunk(size_t alignment, size_t);
-};
-DECLARE_STATIC_PER_PROCESS_STORAGE(VMHeap);
-
-} // namespace bmalloc
-
-#endif // VMHeap_h

Modified: trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj (256087 => 256088)


--- trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj	2020-02-08 06:08:33 UTC (rev 256087)
+++ trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj	2020-02-08 10:35:40 UTC (rev 256088)
@@ -78,7 +78,6 @@
 		0F7EB85A1F955A1100F1ABCB /* DeferredDecommitInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F7EB8591F955A0F00F1ABCB /* DeferredDecommitInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0FD557331F7EDB7B00B1F0A3 /* HeapKind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FD557321F7EDB7B00B1F0A3 /* HeapKind.cpp */; };
 		1400274918F89C1300115C97 /* Heap.h in Headers */ = {isa = PBXBuildFile; fileRef = 14DA320C18875B09007269E0 /* Heap.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		1400274A18F89C2300115C97 /* VMHeap.h in Headers */ = {isa = PBXBuildFile; fileRef = 144F7BFC18BFC517003537F3 /* VMHeap.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		140FA00319CE429C00FFD3C8 /* BumpRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 140FA00219CE429C00FFD3C8 /* BumpRange.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		140FA00519CE4B6800FFD3C8 /* LineMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 140FA00419CE4B6800FFD3C8 /* LineMetadata.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		141D9B001C8E51C0000ABBA0 /* List.h in Headers */ = {isa = PBXBuildFile; fileRef = 141D9AFF1C8E51C0000ABBA0 /* List.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -125,7 +124,6 @@
 		14F271C518EA397E008C152F /* Deallocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 145F6859179DC90200D65598 /* Deallocator.cpp */; };
 		14F271C718EA3990008C152F /* Heap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14DA320E18875D9F007269E0 /* Heap.cpp */; };
 		14F271C818EA3990008C152F /* ObjectType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14105E8318E14374003A106E /* ObjectType.cpp */; };
-		14F271C918EA3990008C152F /* VMHeap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 144F7BFB18BFC517003537F3 /* VMHeap.cpp */; };
 		4426E2801C838EE0008EB042 /* Logging.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4426E27E1C838EE0008EB042 /* Logging.cpp */; };
 		4426E2811C838EE0008EB042 /* Logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 4426E27F1C838EE0008EB042 /* Logging.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		4426E2831C839547008EB042 /* BSoftLinking.h in Headers */ = {isa = PBXBuildFile; fileRef = 4426E2821C839547008EB042 /* BSoftLinking.h */; };
@@ -253,8 +251,6 @@
 		144BE11E1CA346520099C8C0 /* Object.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Object.h; path = bmalloc/Object.h; sourceTree = "<group>"; };
 		144C07F21C7B70260051BB6A /* LargeMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LargeMap.cpp; path = bmalloc/LargeMap.cpp; sourceTree = "<group>"; };
 		144C07F31C7B70260051BB6A /* LargeMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LargeMap.h; path = bmalloc/LargeMap.h; sourceTree = "<group>"; };
-		144F7BFB18BFC517003537F3 /* VMHeap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VMHeap.cpp; path = bmalloc/VMHeap.cpp; sourceTree = "<group>"; };
-		144F7BFC18BFC517003537F3 /* VMHeap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VMHeap.h; path = bmalloc/VMHeap.h; sourceTree = "<group>"; };
 		1452478618BC757C00F80098 /* SmallLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SmallLine.h; path = bmalloc/SmallLine.h; sourceTree = "<group>"; };
 		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; };
 		145F6856179DC8CA00D65598 /* Allocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = Allocator.h; path = bmalloc/Allocator.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
@@ -500,8 +496,6 @@
 				0F5BF1501F22E1570029D91D /* Scavenger.cpp */,
 				0F5BF1511F22E1570029D91D /* Scavenger.h */,
 				145F6874179DF84100D65598 /* Sizes.h */,
-				144F7BFB18BFC517003537F3 /* VMHeap.cpp */,
-				144F7BFC18BFC517003537F3 /* VMHeap.h */,
 				1440AFCC1A9527AF00837FAA /* Zone.cpp */,
 				1440AFCA1A95261100837FAA /* Zone.h */,
 			);
@@ -668,7 +662,6 @@
 				14DD78CE18F48D7500950702 /* Syscall.h in Headers */,
 				14DD78CF18F48D7500950702 /* Vector.h in Headers */,
 				14DD78D018F48D7500950702 /* VMAllocate.h in Headers */,
-				1400274A18F89C2300115C97 /* VMHeap.h in Headers */,
 				1440AFCB1A95261100837FAA /* Zone.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -786,7 +779,6 @@
 				0F26A7A5205483130090A141 /* PerProcess.cpp in Sources */,
 				AD14AD2A202529C700890E3B /* ProcessCheck.mm in Sources */,
 				0F5BF1521F22E1570029D91D /* Scavenger.cpp in Sources */,
-				14F271C918EA3990008C152F /* VMHeap.cpp in Sources */,
 				1440AFCD1A9527AF00837FAA /* Zone.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to