Title: [236900] trunk/Source/_javascript_Core
Revision
236900
Author
[email protected]
Date
2018-10-06 12:49:45 -0700 (Sat, 06 Oct 2018)

Log Message

[JSC] Use new extra memory reporting in SparseArrayMap
https://bugs.webkit.org/show_bug.cgi?id=190278

Reviewed by Keith Miller.

This patch switches the extra memory reporting mechanism from deprecatedReportExtraMemory
to reportExtraMemoryAllocated & reportExtraMemoryVisited in SparseArrayMap.

* runtime/SparseArrayValueMap.cpp:
(JSC::SparseArrayValueMap::add):
(JSC::SparseArrayValueMap::visitChildren):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (236899 => 236900)


--- trunk/Source/_javascript_Core/ChangeLog	2018-10-06 19:10:31 UTC (rev 236899)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-10-06 19:49:45 UTC (rev 236900)
@@ -1,5 +1,19 @@
 2018-10-05  Yusuke Suzuki  <[email protected]>
 
+        [JSC] Use new extra memory reporting in SparseArrayMap
+        https://bugs.webkit.org/show_bug.cgi?id=190278
+
+        Reviewed by Keith Miller.
+
+        This patch switches the extra memory reporting mechanism from deprecatedReportExtraMemory
+        to reportExtraMemoryAllocated & reportExtraMemoryVisited in SparseArrayMap.
+
+        * runtime/SparseArrayValueMap.cpp:
+        (JSC::SparseArrayValueMap::add):
+        (JSC::SparseArrayValueMap::visitChildren):
+
+2018-10-05  Yusuke Suzuki  <[email protected]>
+
         [JSC][Linux] Support Perf JITDump logging
         https://bugs.webkit.org/show_bug.cgi?id=189893
 

Modified: trunk/Source/_javascript_Core/runtime/SparseArrayValueMap.cpp (236899 => 236900)


--- trunk/Source/_javascript_Core/runtime/SparseArrayValueMap.cpp	2018-10-06 19:10:31 UTC (rev 236899)
+++ trunk/Source/_javascript_Core/runtime/SparseArrayValueMap.cpp	2018-10-06 19:49:45 UTC (rev 236900)
@@ -69,18 +69,18 @@
 SparseArrayValueMap::AddResult SparseArrayValueMap::add(JSObject* array, unsigned i)
 {
     AddResult result;
-    size_t capacity;
+    size_t increasedCapacity = 0;
     {
         auto locker = holdLock(cellLock());
         result = m_map.add(i, SparseArrayEntry());
-        capacity = m_map.capacity();
+        size_t capacity = m_map.capacity();
+        if (capacity > m_reportedCapacity) {
+            increasedCapacity = capacity - m_reportedCapacity;
+            m_reportedCapacity = capacity;
+        }
     }
-    if (capacity > m_reportedCapacity) {
-        // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated.
-        // https://bugs.webkit.org/show_bug.cgi?id=142595
-        Heap::heap(array)->deprecatedReportExtraMemory((capacity - m_reportedCapacity) * (sizeof(unsigned) + sizeof(WriteBarrier<Unknown>)));
-        m_reportedCapacity = capacity;
-    }
+    if (increasedCapacity)
+        Heap::heap(array)->reportExtraMemoryAllocated(increasedCapacity * sizeof(Map::KeyValuePairType));
     return result;
 }
 
@@ -212,15 +212,16 @@
     return Base::get();
 }
 
-void SparseArrayValueMap::visitChildren(JSCell* thisObject, SlotVisitor& visitor)
+void SparseArrayValueMap::visitChildren(JSCell* cell, SlotVisitor& visitor)
 {
-    Base::visitChildren(thisObject, visitor);
-
-    auto locker = holdLock(thisObject->cellLock());
-    SparseArrayValueMap* thisMap = jsCast<SparseArrayValueMap*>(thisObject);
-    iterator end = thisMap->m_map.end();
-    for (iterator it = thisMap->m_map.begin(); it != end; ++it)
-        visitor.append(it->value.asValue());
+    Base::visitChildren(cell, visitor);
+    SparseArrayValueMap* thisObject = jsCast<SparseArrayValueMap*>(cell);
+    {
+        auto locker = holdLock(thisObject->cellLock());
+        for (auto& entry : thisObject->m_map)
+            visitor.append(entry.value.asValue());
+    }
+    visitor.reportExtraMemoryVisited(thisObject->m_reportedCapacity * sizeof(Map::KeyValuePairType));
 }
 
 } // namespace JSC
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to