Reviewers: fschneider, Kevin Millikin,
Description:
use a worklist in HGraph::InsertRepresentationChanges
* src/hydrogen.cc (HGraph::InsertRepresentationChanges): Use a worklist
instead of a change flag, as suggested in a comment.
BUG=
TEST=test suite passes
Please review this at http://codereview.chromium.org/7477052/
SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/hydrogen.cc
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
a6205ecdf5a6de3e10dbd6cd219a6faef1010434..56a24c8cd96d124557c81425f0de106ba7565ae3
100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -1879,29 +1879,40 @@ void HGraph::InsertRepresentationChanges() {
// int32-phis allow truncation and iteratively remove the ones that
// are used in an operation that does not allow a truncating
// conversion.
- // TODO(fschneider): Replace this with a worklist-based iteration.
- for (int i = 0; i < phi_list()->length(); i++) {
+ int truncating_phis = 0;
+ for (int i = 0; i < phi_list()->length(); ++i) {
HPhi* phi = phi_list()->at(i);
if (phi->representation().IsInteger32()) {
+ ++truncating_phis;
phi->SetFlag(HValue::kTruncatingToInt32);
}
}
- bool change = true;
- while (change) {
- change = false;
- for (int i = 0; i < phi_list()->length(); i++) {
- HPhi* phi = phi_list()->at(i);
- if (!phi->CheckFlag(HValue::kTruncatingToInt32)) continue;
+
+ ZoneList<HPhi*> worklist(truncating_phis);
+ for (int i = 0; i < phi_list()->length(); ++i) {
+ HPhi* phi = phi_list()->at(i);
+ if (phi->CheckFlag (HValue::kTruncatingToInt32)) {
for (HUseIterator it(phi->uses()); !it.Done(); it.Advance()) {
HValue* use = it.value();
if (!use->CheckFlag(HValue::kTruncatingToInt32)) {
phi->ClearFlag(HValue::kTruncatingToInt32);
- change = true;
+ worklist.Add (phi);
break;
}
}
}
}
+
+ while (!worklist.is_empty()) {
+ HPhi* phi = worklist.RemoveLast();
+ for (int i = 0; i < phi->OperandCount(); ++i) {
+ HValue *v = phi->OperandAt(i);
+ if (v->IsPhi() && v->CheckFlag(HValue::kTruncatingToInt32)) {
+ v->ClearFlag(HValue::kTruncatingToInt32);
+ worklist.Add(HPhi::cast(v));
+ }
+ }
+ }
for (int i = 0; i < blocks_.length(); ++i) {
// Process phi instructions first.
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev