Visiting a WeakBlock should report bytes visited, since we reported them allocated.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Feb 2016 16:25:22 +0000 (16:25 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Feb 2016 16:25:22 +0000 (16:25 +0000)
<https://webkit.org/b/153978>

Reviewed by Darin Adler.

When creating a WeakBlock, we tell Heap that we've allocated 1 KB (WeakBlock::blockSize)
of memory. Consequently, when visiting a WeakBlock, we should also report 1 KB of memory
visited. Otherwise Heap will think that those 1 KB already went away.

This was causing us to underestimate heap size, which affects collection scheduling.

* heap/SlotVisitor.h:
(JSC::SlotVisitor::reportMemoryVisited):
* heap/WeakBlock.cpp:
(JSC::WeakBlock::visit):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196251 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/SlotVisitor.h
Source/JavaScriptCore/heap/WeakBlock.cpp

index a78d115..fd81cc2 100644 (file)
@@ -1,3 +1,21 @@
+2016-02-08  Andreas Kling  <akling@apple.com>
+
+        Visiting a WeakBlock should report bytes visited, since we reported them allocated.
+        <https://webkit.org/b/153978>
+
+        Reviewed by Darin Adler.
+
+        When creating a WeakBlock, we tell Heap that we've allocated 1 KB (WeakBlock::blockSize)
+        of memory. Consequently, when visiting a WeakBlock, we should also report 1 KB of memory
+        visited. Otherwise Heap will think that those 1 KB already went away.
+
+        This was causing us to underestimate heap size, which affects collection scheduling.
+
+        * heap/SlotVisitor.h:
+        (JSC::SlotVisitor::reportMemoryVisited):
+        * heap/WeakBlock.cpp:
+        (JSC::WeakBlock::visit):
+
 2016-02-07  Saam barati  <sbarati@apple.com>
 
         Follow up patch to: [ES6] bound functions .name property should be "bound " + the target function's name 
index add2965..ddc112a 100644 (file)
@@ -105,6 +105,7 @@ public:
     void copyLater(JSCell*, CopyToken, void*, size_t);
     
     void reportExtraMemoryVisited(size_t);
+    void reportMemoryVisited(size_t bytes) { m_bytesVisited += bytes; }
     
     void addWeakReferenceHarvester(WeakReferenceHarvester*);
     void addUnconditionalFinalizer(UnconditionalFinalizer*);
index 4b2ae66..5df03d1 100644 (file)
@@ -109,6 +109,8 @@ void WeakBlock::visit(HeapRootVisitor& heapRootVisitor)
 
     SlotVisitor& visitor = heapRootVisitor.visitor();
 
+    visitor.reportMemoryVisited(WeakBlock::blockSize);
+
     for (size_t i = 0; i < weakImplCount(); ++i) {
         WeakImpl* weakImpl = &weakImpls()[i];
         if (weakImpl->state() != WeakImpl::Live)