Reviewers: fschneider,

Message:
It turned out that my original CL that replaces ClearOperands in GVN had a bug, which I fixed. So now doing the same for RemovePhi works too. Mjsunit, Mozilla
and Sputnik tests all pass in debug mode.

PTAL.

Description:
Speed up removing phi nodes.


BUG=
TEST=


Please review this at http://codereview.chromium.org/9452022/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/hydrogen-instructions.h
  M src/hydrogen-instructions.cc
  M src/hydrogen.cc


Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index 3b0b367da8674fc6442984e0fe01001bb7e98aae..2b744eede4898accea98f3ea22717e2584c8ae68 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -383,19 +383,7 @@ void HValue::DeleteAndReplaceWith(HValue* other) {
   // We replace all uses first, so Delete can assert that there are none.
   if (other != NULL) ReplaceAllUsesWith(other);
   ASSERT(HasNoUses());
- // Clearing the operands includes going through the use list of each operand - // to remove this HValue, which can be expensive. Instead, we mark this as
-  // dead and only check the first item in the use list of each operand.
- // For the following items in the use lists we rely on the tail() method to
-  // skip dead dead items and remove them lazily.
-  SetFlag(kIsDead);
-  for (int i = 0; i < OperandCount(); ++i) {
-    HValue* operand = OperandAt(i);
-    HUseListNode* first = operand->use_list_;
-    if (first != NULL && first->index() == i && first->value() == this) {
-      operand->use_list_ = first->tail();
-    }
-  }
+  Kill();
   DeleteFromGraph();
 }

@@ -413,9 +401,17 @@ void HValue::ReplaceAllUsesWith(HValue* other) {
 }


-void HValue::ClearOperands() {
+void HValue::Kill() {
+  // Instead of going through the entire use list of each operand, we only
+  // check the first item in each use list and rely on the tail() method to
+  // skip dead items, removing them lazily next time we traverse the list.
+  SetFlag(kIsDead);
   for (int i = 0; i < OperandCount(); ++i) {
-    SetOperandAt(i, NULL);
+    HValue* operand = OperandAt(i);
+    HUseListNode* first = operand->use_list_;
+    if (first != NULL && first->index() == i && first->value() == this) {
+      operand->use_list_ = first->tail();
+    }
   }
 }

Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index 4a01085043960f0881b3a28edee51c5c606b4ced..011529d6cdfd94f85f2029b93e93ee07333d6e19 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -631,7 +631,9 @@ class HValue: public ZoneObject {
     return use_list_ != NULL && use_list_->tail() != NULL;
   }
   int UseCount() const;
-  void ClearOperands();
+
+ // Mark this HValue as dead and to be removed from other HValues' use lists.
+  void Kill();

   int flags() const { return flags_; }
   void SetFlag(Flag f) { flags_ |= (1 << f); }
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 9918e8518096044441006ae7a39ec0fe137b169d..6bc8af595d2eb26ac0fb069351560dbf8faad410 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -97,7 +97,7 @@ void HBasicBlock::RemovePhi(HPhi* phi) {
   ASSERT(phi->block() == this);
   ASSERT(phis_.Contains(phi));
   ASSERT(phi->HasNoUses() || !phi->is_live());
-  phi->ClearOperands();
+  phi->Kill();
   phis_.RemoveElement(phi);
   phi->SetBlock(NULL);
 }


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to