Title: [276655] trunk/Source/_javascript_Core
Revision
276655
Author
keith_mil...@apple.com
Date
2021-04-27 12:49:45 -0700 (Tue, 27 Apr 2021)

Log Message

StructureStubInfo and PolymorphicAccess should account for their non-GC memory
https://bugs.webkit.org/show_bug.cgi?id=225113

Reviewed by Mark Lam.

We don't pass the ConcurrentJSLocker to the helper methods here since the
DECLARE_VISIT_AGGREGATE macro does not allow for extra parameters to be passed.
I filed https://bugs.webkit.org/show_bug.cgi?id=225114 to track that.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::JITData::size const):
* bytecode/PolymorphicAccess.cpp:
(JSC::PolymorphicAccess::extraMemoryInBytes const):
* bytecode/PolymorphicAccess.h:
* bytecode/StructureStubInfo.cpp:
(JSC::StructureStubInfo::extraMemoryInBytes):
* bytecode/StructureStubInfo.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (276654 => 276655)


--- trunk/Source/_javascript_Core/ChangeLog	2021-04-27 19:41:22 UTC (rev 276654)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-04-27 19:49:45 UTC (rev 276655)
@@ -1,3 +1,23 @@
+2021-04-27  Keith Miller  <keith_mil...@apple.com>
+
+        StructureStubInfo and PolymorphicAccess should account for their non-GC memory
+        https://bugs.webkit.org/show_bug.cgi?id=225113
+
+        Reviewed by Mark Lam.
+
+        We don't pass the ConcurrentJSLocker to the helper methods here since the
+        DECLARE_VISIT_AGGREGATE macro does not allow for extra parameters to be passed.
+        I filed https://bugs.webkit.org/show_bug.cgi?id=225114 to track that.
+
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::JITData::size const):
+        * bytecode/PolymorphicAccess.cpp:
+        (JSC::PolymorphicAccess::extraMemoryInBytes const):
+        * bytecode/PolymorphicAccess.h:
+        * bytecode/StructureStubInfo.cpp:
+        (JSC::StructureStubInfo::extraMemoryInBytes):
+        * bytecode/StructureStubInfo.h:
+
 2021-04-26  Keith Miller  <keith_mil...@apple.com>
 
         UnlinkedCodeBlock should have better accounting for extra memory

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (276654 => 276655)


--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2021-04-27 19:41:22 UTC (rev 276654)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2021-04-27 19:49:45 UTC (rev 276655)
@@ -1034,6 +1034,8 @@
 {
     size_t size = sizeof(JITData);
     size += m_stubInfos.estimatedAllocationSizeInBytes();
+    for (StructureStubInfo* stub : m_stubInfos)
+        size += stub->extraMemoryInBytes();
     size += m_addICs.estimatedAllocationSizeInBytes();
     size += m_mulICs.estimatedAllocationSizeInBytes();
     size += m_negICs.estimatedAllocationSizeInBytes();

Modified: trunk/Source/_javascript_Core/bytecode/PolymorphicAccess.cpp (276654 => 276655)


--- trunk/Source/_javascript_Core/bytecode/PolymorphicAccess.cpp	2021-04-27 19:41:22 UTC (rev 276654)
+++ trunk/Source/_javascript_Core/bytecode/PolymorphicAccess.cpp	2021-04-27 19:49:45 UTC (rev 276655)
@@ -377,6 +377,20 @@
 
 DEFINE_VISIT_AGGREGATE(PolymorphicAccess);
 
+size_t PolymorphicAccess::extraMemoryInBytes() const
+{
+    size_t size = 0;
+    size += m_list.sizeInBytes();
+    // FIXME: Account for the size of the various access cases.
+    size += m_list.size() * sizeof(AccessCase);
+    if (m_stubRoutine)
+        size += sizeof(JITStubRoutine) + m_stubRoutine->code().size();
+    if (m_watchpoints)
+        size += sizeof(WatchpointsOnStructureStubInfo) + m_watchpoints->extraMemoryInBytes();
+    size += m_weakReferences.byteSize();
+    return size;
+}
+
 void PolymorphicAccess::dump(PrintStream& out) const
 {
     out.print(RawPointer(this), ":[");

Modified: trunk/Source/_javascript_Core/bytecode/PolymorphicAccess.h (276654 => 276655)


--- trunk/Source/_javascript_Core/bytecode/PolymorphicAccess.h	2021-04-27 19:41:22 UTC (rev 276654)
+++ trunk/Source/_javascript_Core/bytecode/PolymorphicAccess.h	2021-04-27 19:49:45 UTC (rev 276655)
@@ -157,6 +157,8 @@
 
     // If this returns false then we are requesting a reset of the owning StructureStubInfo.
     bool visitWeak(VM&) const;
+
+    size_t extraMemoryInBytes() const;
     
     // This returns true if it has marked everything it will ever marked. This can be used as an
     // optimization to then avoid calling this method again during the fixpoint.

Modified: trunk/Source/_javascript_Core/bytecode/StructureStubClearingWatchpoint.cpp (276654 => 276655)


--- trunk/Source/_javascript_Core/bytecode/StructureStubClearingWatchpoint.cpp	2021-04-27 19:41:22 UTC (rev 276654)
+++ trunk/Source/_javascript_Core/bytecode/StructureStubClearingWatchpoint.cpp	2021-04-27 19:49:45 UTC (rev 276655)
@@ -106,6 +106,11 @@
     return &WTF::get<StructureTransitionStructureStubClearingWatchpoint>(holderRef->addWatchpoint(ObjectPropertyCondition()));
 }
 
+size_t WatchpointsOnStructureStubInfo::extraMemoryInBytes() const
+{
+    return m_watchpoints.estimatedAllocationSizeInBytes();
+}
+
 void AdaptiveValueStructureStubClearingWatchpoint::handleFire(VM&, const FireDetail&)
 {
     if (!m_holder->isValid())

Modified: trunk/Source/_javascript_Core/bytecode/StructureStubClearingWatchpoint.h (276654 => 276655)


--- trunk/Source/_javascript_Core/bytecode/StructureStubClearingWatchpoint.h	2021-04-27 19:41:22 UTC (rev 276654)
+++ trunk/Source/_javascript_Core/bytecode/StructureStubClearingWatchpoint.h	2021-04-27 19:49:45 UTC (rev 276655)
@@ -104,6 +104,8 @@
     StructureStubInfo* stubInfo() const { return m_stubInfo; }
 
     bool isValid() const;
+
+    size_t extraMemoryInBytes() const;
     
 private:
     CodeBlock* m_codeBlock;
@@ -110,7 +112,7 @@
     StructureStubInfo* m_stubInfo;
     // FIXME: use less memory for the entries in this Bag:
     // https://bugs.webkit.org/show_bug.cgi?id=202380
-    Bag<WTF::Variant<StructureTransitionStructureStubClearingWatchpoint, AdaptiveValueStructureStubClearingWatchpoint>> m_watchpoints;
+    Bag<Node> m_watchpoints;
 };
 
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/bytecode/StructureStubInfo.cpp (276654 => 276655)


--- trunk/Source/_javascript_Core/bytecode/StructureStubInfo.cpp	2021-04-27 19:41:22 UTC (rev 276654)
+++ trunk/Source/_javascript_Core/bytecode/StructureStubInfo.cpp	2021-04-27 19:49:45 UTC (rev 276655)
@@ -355,6 +355,19 @@
     resetByGC = true;
 }
 
+size_t StructureStubInfo::extraMemoryInBytes()
+{
+    size_t extraMemory = 0;
+    // Cacheable Identifier never owns extra memory because UIDs are owned by the unique string table.
+    {
+        auto locker = holdLock(m_bufferedStructuresLock);
+        extraMemory += m_bufferedStructures.capacity() * sizeof(BufferedStructure);
+    }
+    if (cacheType() == CacheType::Stub)
+        extraMemory += u.stub->extraMemoryInBytes();
+    return extraMemory;
+}
+
 template<typename Visitor>
 bool StructureStubInfo::propagateTransitions(Visitor& visitor)
 {

Modified: trunk/Source/_javascript_Core/bytecode/StructureStubInfo.h (276654 => 276655)


--- trunk/Source/_javascript_Core/bytecode/StructureStubInfo.h	2021-04-27 19:41:22 UTC (rev 276654)
+++ trunk/Source/_javascript_Core/bytecode/StructureStubInfo.h	2021-04-27 19:49:45 UTC (rev 276655)
@@ -98,6 +98,9 @@
     // Check if the stub has weak references that are dead. If it does, then it resets itself,
     // either entirely or just enough to ensure that those dead pointers don't get used anymore.
     void visitWeakReferences(const ConcurrentJSLockerBase&, CodeBlock*);
+
+    // Computes the non-GC memory owned by this object in bytes, recursively requesting the non-GC memory size of owned objects.
+    size_t extraMemoryInBytes();
     
     // This returns true if it has marked everything that it will ever mark.
     template<typename Visitor> bool propagateTransitions(Visitor&);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to