Title: [140030] trunk/Source/_javascript_Core
- Revision
- 140030
- Author
- fpi...@apple.com
- Date
- 2013-01-17 12:45:06 -0800 (Thu, 17 Jan 2013)
Log Message
DFG Node::ref() and Node::deref() should not return bool, and should have postfixRef variants
https://bugs.webkit.org/show_bug.cgi?id=107147
Reviewed by Mark Hahnenberg.
This small refactoring will enable a world where ref() returns Node*, which is useful for
https://bugs.webkit.org/show_bug.cgi?id=106868. Also, while this refactoring does lead to
slightly less terse code, it's also slightly more self-explanatory. I could never quite
remember what the meaning of the bool return from ref() and deref() was.
* dfg/DFGGraph.cpp:
(JSC::DFG::Graph::collectGarbage):
* dfg/DFGGraph.h:
(JSC::DFG::Graph::ref):
(JSC::DFG::Graph::deref):
* dfg/DFGNode.h:
(JSC::DFG::Node::ref):
(Node):
(JSC::DFG::Node::postfixRef):
(JSC::DFG::Node::deref):
(JSC::DFG::Node::postfixDeref):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (140029 => 140030)
--- trunk/Source/_javascript_Core/ChangeLog 2013-01-17 20:40:39 UTC (rev 140029)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-01-17 20:45:06 UTC (rev 140030)
@@ -1,3 +1,27 @@
+2013-01-17 Filip Pizlo <fpi...@apple.com>
+
+ DFG Node::ref() and Node::deref() should not return bool, and should have postfixRef variants
+ https://bugs.webkit.org/show_bug.cgi?id=107147
+
+ Reviewed by Mark Hahnenberg.
+
+ This small refactoring will enable a world where ref() returns Node*, which is useful for
+ https://bugs.webkit.org/show_bug.cgi?id=106868. Also, while this refactoring does lead to
+ slightly less terse code, it's also slightly more self-explanatory. I could never quite
+ remember what the meaning of the bool return from ref() and deref() was.
+
+ * dfg/DFGGraph.cpp:
+ (JSC::DFG::Graph::collectGarbage):
+ * dfg/DFGGraph.h:
+ (JSC::DFG::Graph::ref):
+ (JSC::DFG::Graph::deref):
+ * dfg/DFGNode.h:
+ (JSC::DFG::Node::ref):
+ (Node):
+ (JSC::DFG::Node::postfixRef):
+ (JSC::DFG::Node::deref):
+ (JSC::DFG::Node::postfixDeref):
+
2013-01-17 Alexey Proskuryakov <a...@apple.com>
Added svn:ignore=*.pyc, so that ud_opcode.pyc and ud_optable.pyc don't show up
Modified: trunk/Source/_javascript_Core/dfg/DFGGraph.cpp (140029 => 140030)
--- trunk/Source/_javascript_Core/dfg/DFGGraph.cpp 2013-01-17 20:40:39 UTC (rev 140029)
+++ trunk/Source/_javascript_Core/dfg/DFGGraph.cpp 2013-01-17 20:45:06 UTC (rev 140030)
@@ -488,18 +488,18 @@
if (!m_varArgChildren[childIdx])
continue;
NodeIndex childNodeIndex = m_varArgChildren[childIdx].index();
- if (!at(childNodeIndex).ref())
+ if (at(childNodeIndex).postfixRef())
continue;
worklist.append(childNodeIndex);
}
} else if (node.child1()) {
- if (at(node.child1()).ref())
+ if (!at(node.child1()).postfixRef())
worklist.append(node.child1().index());
if (node.child2()) {
- if (at(node.child2()).ref())
+ if (!at(node.child2()).postfixRef())
worklist.append(node.child2().index());
if (node.child3()) {
- if (at(node.child3()).ref())
+ if (!at(node.child3()).postfixRef())
worklist.append(node.child3().index());
}
}
Modified: trunk/Source/_javascript_Core/dfg/DFGGraph.h (140029 => 140030)
--- trunk/Source/_javascript_Core/dfg/DFGGraph.h 2013-01-17 20:40:39 UTC (rev 140029)
+++ trunk/Source/_javascript_Core/dfg/DFGGraph.h 2013-01-17 20:45:06 UTC (rev 140030)
@@ -103,7 +103,7 @@
{
Node& node = at(nodeIndex);
// If the value (before incrementing) was at refCount zero then we need to ref its children.
- if (node.ref())
+ if (!node.postfixRef())
refChildren(nodeIndex);
}
void ref(Edge nodeUse)
@@ -113,9 +113,7 @@
void deref(NodeIndex nodeIndex)
{
- if (!at(nodeIndex).refCount())
- dump();
- if (at(nodeIndex).deref())
+ if (at(nodeIndex).postfixDeref() == 1)
derefChildren(nodeIndex);
}
void deref(Edge nodeUse)
Modified: trunk/Source/_javascript_Core/dfg/DFGNode.h (140029 => 140030)
--- trunk/Source/_javascript_Core/dfg/DFGNode.h 2013-01-17 20:40:39 UTC (rev 140029)
+++ trunk/Source/_javascript_Core/dfg/DFGNode.h 2013-01-17 20:45:06 UTC (rev 140030)
@@ -909,12 +909,16 @@
return m_refCount;
}
- // returns true when ref count passes from 0 to 1.
- bool ref()
+ void ref()
{
- return !m_refCount++;
+ m_refCount++;
}
+ unsigned postfixRef()
+ {
+ return m_refCount++;
+ }
+
unsigned adjustedRefCount()
{
return mustGenerate() ? m_refCount - 1 : m_refCount;
@@ -925,15 +929,18 @@
m_refCount = refCount;
}
- // Derefs the node and returns true if the ref count reached zero.
- // In general you don't want to use this directly; use Graph::deref
- // instead.
- bool deref()
+ void deref()
{
ASSERT(m_refCount);
- return !--m_refCount;
+ --m_refCount;
}
+ unsigned postfixDeref()
+ {
+ ASSERT(m_refCount);
+ return m_refCount--;
+ }
+
Edge child1()
{
ASSERT(!(m_flags & NodeHasVarArgs));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes