Title: [295059] trunk/Source/WebCore/dom
Revision
295059
Author
[email protected]
Date
2022-05-31 11:00:33 -0700 (Tue, 31 May 2022)

Log Message

Avoid GCReacheableRefMap lookup inside JSNodeOwner::isReachableFromOpaqueRoots()
https://bugs.webkit.org/show_bug.cgi?id=241063

Reviewed by Geoffrey Garen.

Avoid GCReacheableRefMap lookup inside JSNodeOwner::isReachableFromOpaqueRoots()
by leveraging a flag on Node. According to A/B testing this is a ~0.5%
progression on Speedometer on Apple Silicon.

* Source/WebCore/dom/GCReachableRef.h:
(WebCore::GCReachableRefMap::contains):
(WebCore::GCReachableRefMap::add):
(WebCore::GCReachableRefMap::remove):
* Source/WebCore/dom/Node.h:
(WebCore::Node::isInGCReacheableRefMap const):
(WebCore::Node::setIsInGCReacheableRefMap):

Canonical link: https://commits.webkit.org/251154@main

Modified Paths

Diff

Modified: trunk/Source/WebCore/dom/GCReachableRef.h (295058 => 295059)


--- trunk/Source/WebCore/dom/GCReachableRef.h	2022-05-31 17:12:54 UTC (rev 295058)
+++ trunk/Source/WebCore/dom/GCReachableRef.h	2022-05-31 18:00:33 UTC (rev 295059)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "Node.h"
 #include <wtf/HashCountedSet.h>
 #include <wtf/RawPtrTraits.h>
 #include <wtf/RefPtr.h>
@@ -35,9 +36,17 @@
 
 class GCReachableRefMap {
 public:
-    static inline bool contains(Node& node) { return map().contains(&node); }
-    static inline void add(Node& node) { map().add(&node); }
-    static inline void remove(Node& node) { map().remove(&node); }
+    static inline bool contains(Node& node) { return node.isInGCReacheableRefMap(); }
+    static inline void add(Node& node)
+    {
+        if (map().add(&node).isNewEntry)
+            node.setIsInGCReacheableRefMap(true);
+    }
+    static inline void remove(Node& node)
+    {
+        if (map().remove(&node))
+            node.setIsInGCReacheableRefMap(false);
+    }
 
 private:
     static HashCountedSet<Node*>& map();

Modified: trunk/Source/WebCore/dom/Node.h (295058 => 295059)


--- trunk/Source/WebCore/dom/Node.h	2022-05-31 17:12:54 UTC (rev 295058)
+++ trunk/Source/WebCore/dom/Node.h	2022-05-31 18:00:33 UTC (rev 295059)
@@ -330,6 +330,9 @@
     bool hasEventTargetData() const { return hasNodeFlag(NodeFlag::HasEventTargetData); }
     void setHasEventTargetData(bool flag) { setNodeFlag(NodeFlag::HasEventTargetData, flag); }
 
+    bool isInGCReacheableRefMap() const { return hasNodeFlag(NodeFlag::IsInGCReachableRefMap); }
+    void setIsInGCReacheableRefMap(bool flag) { setNodeFlag(NodeFlag::IsInGCReachableRefMap, flag); }
+
     WEBCORE_EXPORT bool isContentEditable() const;
     bool isContentRichlyEditable() const;
 
@@ -569,7 +572,7 @@
         HasCustomStyleResolveCallbacks = 1 << 21,
 
         HasPendingResources = 1 << 22,
-        // Bit 23 is free.
+        IsInGCReachableRefMap = 1 << 23,
 #if ENABLE(FULLSCREEN_API)
         ContainsFullScreenElement = 1 << 24,
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to