Title: [116402] trunk/Source/WebCore
- Revision
- 116402
- Author
- [email protected]
- Date
- 2012-05-08 01:31:29 -0700 (Tue, 08 May 2012)
Log Message
Inline Node::traverseNextNode
https://bugs.webkit.org/show_bug.cgi?id=85844
Reviewed by Ryosuke Niwa.
Inline traverseNextNode and traverseNextSibling to reduce entry/exit overhead and allow better code generation
for many hot loops. Also added separate versions of stayWithin and unscoped cases (the function is
so simple that this seemed like the cleanest way to do it, the most reliable too) and used UNLIKELY for the
end-of-traversal conditions.
The traversal function can show up to ~1% in normal page loading profiles.
run-perf-tests seems to think this is a progression in some subtests though bots will tell for certain.
* WebCore.exp.in:
* dom/ContainerNode.h:
Following the existing pattern, function bodies go to ContainerNode.h so they can call parentNode().
(which returns ContainerNode, not Node).
(WebCore::Node::traverseNextNode):
(WebCore):
(WebCore::Node::traverseNextSibling):
* dom/Node.cpp:
(WebCore):
* dom/Node.h:
(Node):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (116401 => 116402)
--- trunk/Source/WebCore/ChangeLog 2012-05-08 07:34:08 UTC (rev 116401)
+++ trunk/Source/WebCore/ChangeLog 2012-05-08 08:31:29 UTC (rev 116402)
@@ -1,3 +1,33 @@
+2012-05-07 Antti Koivisto <[email protected]>
+
+ Inline Node::traverseNextNode
+ https://bugs.webkit.org/show_bug.cgi?id=85844
+
+ Reviewed by Ryosuke Niwa.
+
+ Inline traverseNextNode and traverseNextSibling to reduce entry/exit overhead and allow better code generation
+ for many hot loops. Also added separate versions of stayWithin and unscoped cases (the function is
+ so simple that this seemed like the cleanest way to do it, the most reliable too) and used UNLIKELY for the
+ end-of-traversal conditions.
+
+ The traversal function can show up to ~1% in normal page loading profiles.
+
+ run-perf-tests seems to think this is a progression in some subtests though bots will tell for certain.
+
+ * WebCore.exp.in:
+ * dom/ContainerNode.h:
+
+ Following the existing pattern, function bodies go to ContainerNode.h so they can call parentNode().
+ (which returns ContainerNode, not Node).
+
+ (WebCore::Node::traverseNextNode):
+ (WebCore):
+ (WebCore::Node::traverseNextSibling):
+ * dom/Node.cpp:
+ (WebCore):
+ * dom/Node.h:
+ (Node):
+
2012-05-05 Pavel Feldman <[email protected]>
Web Inspector: make _javascript_SourceFrame use breakpoint manager's breakpoints store.
Modified: trunk/Source/WebCore/WebCore.exp.in (116401 => 116402)
--- trunk/Source/WebCore/WebCore.exp.in 2012-05-08 07:34:08 UTC (rev 116401)
+++ trunk/Source/WebCore/WebCore.exp.in 2012-05-08 08:31:29 UTC (rev 116402)
@@ -2096,7 +2096,6 @@
__ZN7WebCore8Document36setFullScreenRendererBackgroundColorENS_5ColorE
__ZN7WebCore8Document22setAnimatingFullScreenEb
__ZNK7WebCore8Document9domWindowEv
-__ZNK7WebCore4Node16traverseNextNodeEPKS0_
#endif
__ZN7WebCore16ApplicationCache18diskUsageForOriginEPNS_14SecurityOriginE
Modified: trunk/Source/WebCore/bindings/v8/RetainedDOMInfo.cpp (116401 => 116402)
--- trunk/Source/WebCore/bindings/v8/RetainedDOMInfo.cpp 2012-05-08 07:34:08 UTC (rev 116401)
+++ trunk/Source/WebCore/bindings/v8/RetainedDOMInfo.cpp 2012-05-08 08:31:29 UTC (rev 116402)
@@ -31,7 +31,7 @@
#include "config.h"
#include "RetainedDOMInfo.h"
-#include "Node.h"
+#include "ContainerNode.h"
namespace WebCore {
Modified: trunk/Source/WebCore/dom/ContainerNode.h (116401 => 116402)
--- trunk/Source/WebCore/dom/ContainerNode.h 2012-05-08 07:34:08 UTC (rev 116401)
+++ trunk/Source/WebCore/dom/ContainerNode.h 2012-05-08 08:31:29 UTC (rev 116402)
@@ -228,6 +228,62 @@
return highest;
}
+inline Node* Node::traverseNextNode() const
+{
+ if (firstChild())
+ return firstChild();
+ if (nextSibling())
+ return nextSibling();
+ const Node* node = this;
+ while (node && !node->nextSibling())
+ node = node->parentNode();
+ if (UNLIKELY(!node))
+ return 0;
+ return node->nextSibling();
+}
+
+inline Node* Node::traverseNextNode(const Node* stayWithin) const
+{
+ if (firstChild())
+ return firstChild();
+ if (UNLIKELY(this == stayWithin))
+ return 0;
+ if (nextSibling())
+ return nextSibling();
+ const Node* node = this;
+ while (node && !node->nextSibling() && (!stayWithin || node->parentNode() != stayWithin))
+ node = node->parentNode();
+ if (UNLIKELY(!node))
+ return 0;
+ return node->nextSibling();
+}
+
+inline Node* Node::traverseNextSibling() const
+{
+ if (nextSibling())
+ return nextSibling();
+ const Node* node = this;
+ while (node && !node->nextSibling())
+ node = node->parentNode();
+ if (UNLIKELY(!node))
+ return 0;
+ return node->nextSibling();
+}
+
+inline Node* Node::traverseNextSibling(const Node* stayWithin) const
+{
+ if (UNLIKELY(this == stayWithin))
+ return 0;
+ if (nextSibling())
+ return nextSibling();
+ const Node* node = this;
+ while (node && !node->nextSibling() && (!stayWithin || node->parentNode() != stayWithin))
+ node = node->parentNode();
+ if (UNLIKELY(!node))
+ return 0;
+ return node->nextSibling();
+}
+
typedef Vector<RefPtr<Node>, 11> NodeVector;
inline void getChildNodes(Node* node, NodeVector& nodes)
Modified: trunk/Source/WebCore/dom/Node.cpp (116401 => 116402)
--- trunk/Source/WebCore/dom/Node.cpp 2012-05-08 07:34:08 UTC (rev 116401)
+++ trunk/Source/WebCore/dom/Node.cpp 2012-05-08 08:31:29 UTC (rev 116402)
@@ -1084,36 +1084,6 @@
rareData()->setChildNodeList(0);
}
-Node* Node::traverseNextNode(const Node* stayWithin) const
-{
- if (firstChild())
- return firstChild();
- if (this == stayWithin)
- return 0;
- if (nextSibling())
- return nextSibling();
- const Node *n = this;
- while (n && !n->nextSibling() && (!stayWithin || n->parentNode() != stayWithin))
- n = n->parentNode();
- if (n)
- return n->nextSibling();
- return 0;
-}
-
-Node* Node::traverseNextSibling(const Node* stayWithin) const
-{
- if (this == stayWithin)
- return 0;
- if (nextSibling())
- return nextSibling();
- const Node *n = this;
- while (n && !n->nextSibling() && (!stayWithin || n->parentNode() != stayWithin))
- n = n->parentNode();
- if (n)
- return n->nextSibling();
- return 0;
-}
-
Node* Node::traverseNextNodePostOrder() const
{
Node* next = nextSibling();
Modified: trunk/Source/WebCore/dom/Node.h (116401 => 116402)
--- trunk/Source/WebCore/dom/Node.h 2012-05-08 07:34:08 UTC (rev 116401)
+++ trunk/Source/WebCore/dom/Node.h 2012-05-08 08:31:29 UTC (rev 116402)
@@ -427,10 +427,12 @@
// This uses the same order that tags appear in the source file. If the stayWithin
// argument is non-null, the traversal will stop once the specified node is reached.
// This can be used to restrict traversal to a particular sub-tree.
- Node* traverseNextNode(const Node* stayWithin = 0) const;
+ Node* traverseNextNode() const;
+ Node* traverseNextNode(const Node* stayWithin) const;
// Like traverseNextNode, but skips children and starts with the next sibling.
- Node* traverseNextSibling(const Node* stayWithin = 0) const;
+ Node* traverseNextSibling() const;
+ Node* traverseNextSibling(const Node* stayWithin) const;
// Does a reverse pre-order traversal to find the node that comes before the current one in document order
Node* traversePreviousNode(const Node* stayWithin = 0) const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes