Title: [283264] trunk/Source/bmalloc
Revision
283264
Author
[email protected]
Date
2021-09-29 14:45:04 -0700 (Wed, 29 Sep 2021)

Log Message

Unreviewed, reverting r282850.

Patch causing many crashes in
bmalloc::Heap::decommitLargeRange

Reverted changeset:

"[bmalloc] freeableMemory and footprint of Heap are completely
broken"
https://bugs.webkit.org/show_bug.cgi?id=230245
https://commits.webkit.org/r282850

Modified Paths

Diff

Modified: trunk/Source/bmalloc/ChangeLog (283263 => 283264)


--- trunk/Source/bmalloc/ChangeLog	2021-09-29 21:16:28 UTC (rev 283263)
+++ trunk/Source/bmalloc/ChangeLog	2021-09-29 21:45:04 UTC (rev 283264)
@@ -1,3 +1,17 @@
+2021-09-29  Eric Hutchison  <[email protected]>
+
+        Unreviewed, reverting r282850.
+
+        Patch causing many crashes in
+        bmalloc::Heap::decommitLargeRange
+
+        Reverted changeset:
+
+        "[bmalloc] freeableMemory and footprint of Heap are completely
+        broken"
+        https://bugs.webkit.org/show_bug.cgi?id=230245
+        https://commits.webkit.org/r282850
+
 2021-09-27  Filip Pizlo  <[email protected]>
 
         [libpas] Fix coalescing of the large sharing pool and make it easy to introspect it (update to e4d20851ee9ff00f2962b349a9ff8465695a83d7)

Modified: trunk/Source/bmalloc/bmalloc/Heap.cpp (283263 => 283264)


--- trunk/Source/bmalloc/bmalloc/Heap.cpp	2021-09-29 21:16:28 UTC (rev 283263)
+++ trunk/Source/bmalloc/bmalloc/Heap.cpp	2021-09-29 21:45:04 UTC (rev 283264)
@@ -99,38 +99,6 @@
     return m_footprint;
 }
 
-BINLINE void Heap::adjustStat(size_t& value, ssize_t amount)
-{
-    auto result = value + amount;
-    BASSERT((amount >= 0 && result >= value) || (amount < 0 && result < value));
-    value = result;
-}
-
-BINLINE void Heap::logStat(size_t value, ssize_t amount, const char* label, const char* note)
-{
-    fprintf(stderr, "%s: %lu (%ld) %s\n", label, value, amount, note);
-}
-
-BINLINE void Heap::adjustFreeableMemory(UniqueLockHolder&, ssize_t amount, const char* note)
-{
-    constexpr bool verbose = false;
-
-    adjustStat(m_freeableMemory, amount);
-
-    if constexpr (verbose)
-        logStat(m_freeableMemory, amount, "freeableMemory", note);
-}
-
-BINLINE void Heap::adjustFootprint(UniqueLockHolder&, ssize_t amount, const char* note)
-{
-    constexpr bool verbose = false;
-
-    adjustStat(m_footprint, amount);
-
-    if constexpr (verbose)
-        logStat(m_footprint, amount, "footprint", note);
-}
-
 void Heap::markAllLargeAsEligibile(const LockHolder&)
 {
     m_largeFree.markAllAsEligibile();
@@ -138,12 +106,12 @@
     m_condition.notify_all();
 }
 
-void Heap::decommitLargeRange(UniqueLockHolder& lock, LargeRange& range, BulkDecommit& decommitter)
+void Heap::decommitLargeRange(UniqueLockHolder&, LargeRange& range, BulkDecommit& decommitter)
 {
     BASSERT(range.hasPhysicalPages());
 
-    adjustFootprint(lock, -range.totalPhysicalSize(), "decommitLargeRange");
-    adjustFreeableMemory(lock, -range.totalPhysicalSize(), "decommitLargeRange");
+    m_footprint -= range.totalPhysicalSize();
+    m_freeableMemory -= range.totalPhysicalSize();
     decommitter.addLazy(range.begin(), range.physicalEnd() - range.begin());
     m_hasPendingDecommits = true;
     range.setStartPhysicalSize(0);
@@ -171,8 +139,8 @@
 
                 size_t pageSize = bmalloc::pageSize(&list - &m_freePages[0]);
                 size_t decommitSize = physicalPageSizeSloppy(page->begin()->begin(), pageSize);
-                adjustFootprint(lock, -decommitSize, "scavenge");
-                adjustFreeableMemory(lock, -decommitSize, "scavenge");
+                m_freeableMemory -= decommitSize;
+                m_footprint -= decommitSize;
                 decommitter.addEager(page->begin()->begin(), pageSize);
                 page->setHasPhysicalPages(false);
 #if ENABLE_PHYSICAL_PAGE_MAP
@@ -237,7 +205,7 @@
             chunk->freePages().push(page);
         });
 
-        adjustFreeableMemory(lock, chunkSize, "allocateSmallChunk");
+        m_freeableMemory += chunkSize;
 
         m_scavenger->schedule(0);
 
@@ -307,10 +275,10 @@
         size_t pageSize = bmalloc::pageSize(pageClass);
         size_t physicalSize = physicalPageSizeSloppy(page->begin()->begin(), pageSize);
         if (page->hasPhysicalPages())
-            adjustFreeableMemory(lock, -physicalSize, "allocateSmallPage");
+            m_freeableMemory -= physicalSize;
         else {
             m_scavenger->scheduleIfUnderMemoryPressure(pageSize);
-            adjustFootprint(lock, physicalSize, "allocateSmallPage");
+            m_footprint += physicalSize;
             vmAllocatePhysicalPagesSloppy(page->begin()->begin(), pageSize);
             page->setHasPhysicalPages(true);
 #if ENABLE_PHYSICAL_PAGE_MAP
@@ -346,7 +314,7 @@
 
     size_t pageClass = m_constants.pageClass(page->sizeClass());
 
-    adjustFreeableMemory(lock, physicalPageSizeSloppy(page->begin()->begin(), pageSize(pageClass)), "deallocateSmallLine");
+    m_freeableMemory += physicalPageSizeSloppy(page->begin()->begin(), pageSize(pageClass));
 
     List<SmallPage>::remove(page); // 'page' may be in any thread's line cache.
     
@@ -522,7 +490,7 @@
     
     if (range.startPhysicalSize() < range.size()) {
         m_scavenger->scheduleIfUnderMemoryPressure(range.size());
-        adjustFootprint(lock, range.size() - range.totalPhysicalSize(), "splitAndAllocate");
+        m_footprint += range.size() - range.totalPhysicalSize();
         vmAllocatePhysicalPagesSloppy(range.begin() + range.startPhysicalSize(), range.size() - range.startPhysicalSize());
         range.setStartPhysicalSize(range.size());
         range.setTotalPhysicalSize(range.size());
@@ -533,12 +501,12 @@
     }
     
     if (prev) {
-        adjustFreeableMemory(lock, prev.totalPhysicalSize(), "splitAndAllocate.prev");
+        m_freeableMemory += prev.totalPhysicalSize();
         m_largeFree.add(prev);
     }
 
     if (next) {
-        adjustFreeableMemory(lock, next.totalPhysicalSize(), "splitAndAllocate.next");
+        m_freeableMemory += next.totalPhysicalSize();
         m_largeFree.add(next);
     }
 
@@ -584,13 +552,11 @@
         ASSERT_OR_RETURN_ON_FAILURE(range);
         
         m_largeFree.add(range);
-        adjustFreeableMemory(lock, range.totalPhysicalSize(), "allocateLarge");
-        adjustFootprint(lock, range.totalPhysicalSize(), "allocateLarge");
-
         range = m_largeFree.remove(alignment, size);
     }
-    adjustFreeableMemory(lock, -range.totalPhysicalSize(), "allocateLarge.reuse");
 
+    m_freeableMemory -= range.totalPhysicalSize();
+
     void* result = splitAndAllocate(lock, range, alignment, size).begin();
     ASSERT_OR_RETURN_ON_FAILURE(result);
     return result;
@@ -639,11 +605,11 @@
     m_scavenger->schedule(size);
 }
 
-void Heap::deallocateLarge(UniqueLockHolder& lock, void* object)
+void Heap::deallocateLarge(UniqueLockHolder&, void* object)
 {
     size_t size = m_largeAllocated.remove(object);
     m_largeFree.add(LargeRange(object, size, size, size, static_cast<char*>(object) + size));
-    adjustFreeableMemory(lock, size, "deallocateLarge");
+    m_freeableMemory += size;
     m_scavenger->schedule(size);
 }
 
@@ -653,11 +619,11 @@
     externalCommit(lock, ptr, size);
 }
 
-void Heap::externalCommit(UniqueLockHolder& lock, void* ptr, size_t size)
+void Heap::externalCommit(UniqueLockHolder&, void* ptr, size_t size)
 {
     BUNUSED_PARAM(ptr);
 
-    adjustFootprint(lock, size, "externalCommit");
+    m_footprint += size;
 #if ENABLE_PHYSICAL_PAGE_MAP 
     m_physicalPageMap.commit(ptr, size);
 #endif
@@ -669,11 +635,11 @@
     externalDecommit(lock, ptr, size);
 }
 
-void Heap::externalDecommit(UniqueLockHolder& lock, void* ptr, size_t size)
+void Heap::externalDecommit(UniqueLockHolder&, void* ptr, size_t size)
 {
     BUNUSED_PARAM(ptr);
 
-    adjustFootprint(lock, -size, "externalDecommit");
+    m_footprint -= size;
 #if ENABLE_PHYSICAL_PAGE_MAP 
     m_physicalPageMap.decommit(ptr, size);
 #endif

Modified: trunk/Source/bmalloc/bmalloc/Heap.h (283263 => 283264)


--- trunk/Source/bmalloc/bmalloc/Heap.h	2021-09-29 21:16:28 UTC (rev 283263)
+++ trunk/Source/bmalloc/bmalloc/Heap.h	2021-09-29 21:45:04 UTC (rev 283264)
@@ -117,11 +117,6 @@
     LargeRange tryAllocateLargeChunk(size_t alignment, size_t);
     LargeRange splitAndAllocate(UniqueLockHolder&, LargeRange&, size_t alignment, size_t);
 
-    inline void adjustFootprint(UniqueLockHolder&, ssize_t, const char* note);
-    inline void adjustFreeableMemory(UniqueLockHolder&, ssize_t, const char* note);
-    inline void adjustStat(size_t& value, ssize_t);
-    inline void logStat(size_t value, ssize_t amount, const char* label, const char* note);
-
     HeapKind m_kind;
     HeapConstants& m_constants;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to