Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Unified Diff: src/hydrogen.cc

Issue 7477052: use a worklist in HGraph::InsertRepresentationChanges (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698