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

Side by Side Diff: runtime/vm/flow_graph_optimizer.cc

Issue 328743003: Update use lists after eliminating redundant phis. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed comments Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« runtime/vm/compiler.cc ('K') | « runtime/vm/compiler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/flow_graph_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 7187 matching lines...) Expand 10 before | Expand all | Expand 10 after
7198 7198
7199 // At this point worklist contains pairs of equal phis. Replace the first 7199 // At this point worklist contains pairs of equal phis. Replace the first
7200 // phi in the pair with the second. 7200 // phi in the pair with the second.
7201 for (intptr_t i = 0; i < worklist_.length(); i += 2) { 7201 for (intptr_t i = 0; i < worklist_.length(); i += 2) {
7202 PhiInstr* a = worklist_[i]; 7202 PhiInstr* a = worklist_[i];
7203 PhiInstr* b = worklist_[i + 1]; 7203 PhiInstr* b = worklist_[i + 1];
7204 a->ReplaceUsesWith(b); 7204 a->ReplaceUsesWith(b);
7205 if (a->is_alive()) { 7205 if (a->is_alive()) {
7206 a->mark_dead(); 7206 a->mark_dead();
7207 a->block()->RemovePhi(a); 7207 a->block()->RemovePhi(a);
7208 a->UnuseAllInputs();
7208 } 7209 }
7209 } 7210 }
7210
7211 return true; 7211 return true;
7212 } 7212 }
7213 7213
7214 // Insert the given phi into the graph. Attempt to find an equal one in the 7214 // Insert the given phi into the graph. Attempt to find an equal one in the
7215 // target block first. 7215 // target block first.
7216 // Returns true if the phi was inserted and false if it was replaced. 7216 // Returns true if the phi was inserted and false if it was replaced.
7217 bool EmitPhi(PhiInstr* phi) { 7217 bool EmitPhi(PhiInstr* phi) {
7218 for (PhiIterator it(phi->block()); !it.Done(); it.Advance()) { 7218 for (PhiIterator it(phi->block()); !it.Done(); it.Advance()) {
7219 if (ReplacePhiWith(phi, it.Current())) { 7219 if (ReplacePhiWith(phi, it.Current())) {
7220 return false; 7220 return false;
7221 } 7221 }
7222 } 7222 }
7223 7223
7224 phi->mark_alive(); 7224 phi->mark_alive();
7225 phi->block()->InsertPhi(phi); 7225 phi->block()->InsertPhi(phi);
7226 return true; 7226 return true;
7227 } 7227 }
7228 7228
7229 // Phis have not yet been inserted into the graph but they have uses of 7229 // Phis have not yet been inserted into the graph but they have uses of
7230 // their inputs. Insert the non-redundant ones and clear the input uses 7230 // their inputs. Insert the non-redundant ones and clear the input uses
7231 // of the redundant ones. 7231 // of the redundant ones.
7232 void EmitPhis() { 7232 void EmitPhis() {
7233 // First eliminate all redundant phis. 7233 // First eliminate all redundant phis.
7234 for (intptr_t i = 0; i < phis_.length(); i++) { 7234 for (intptr_t i = 0; i < phis_.length(); i++) {
7235 PhiInstr* phi = phis_[i]; 7235 PhiInstr* phi = phis_[i];
7236 if (!phi->HasUses() || EliminateRedundantPhi(phi)) { 7236 if (!phi->HasUses() || EliminateRedundantPhi(phi)) {
7237 for (intptr_t j = phi->InputCount() - 1; j >= 0; --j) { 7237 phi->UnuseAllInputs();
7238 phi->InputAt(j)->RemoveFromUseList();
7239 }
7240 phis_[i] = NULL; 7238 phis_[i] = NULL;
7241 } 7239 }
7242 } 7240 }
7243 7241
7244 // Now emit phis or replace them with equal phis already present in the 7242 // Now emit phis or replace them with equal phis already present in the
7245 // graph. 7243 // graph.
7246 for (intptr_t i = 0; i < phis_.length(); i++) { 7244 for (intptr_t i = 0; i < phis_.length(); i++) {
7247 PhiInstr* phi = phis_[i]; 7245 PhiInstr* phi = phis_[i];
7248 if ((phi != NULL) && (!phi->HasUses() || !EmitPhi(phi))) { 7246 if ((phi != NULL) && (!phi->HasUses() || !EmitPhi(phi))) {
7249 for (intptr_t j = phi->InputCount() - 1; j >= 0; --j) { 7247 phi->UnuseAllInputs();
7250 phi->InputAt(j)->RemoveFromUseList();
7251 }
7252 } 7248 }
7253 } 7249 }
7254 } 7250 }
7255 7251
7256 ZoneGrowableArray<Definition*>* CreateBlockOutValues() { 7252 ZoneGrowableArray<Definition*>* CreateBlockOutValues() {
7257 ZoneGrowableArray<Definition*>* out = 7253 ZoneGrowableArray<Definition*>* out =
7258 new(isolate()) ZoneGrowableArray<Definition*>( 7254 new(isolate()) ZoneGrowableArray<Definition*>(
7259 aliased_set_->max_place_id()); 7255 aliased_set_->max_place_id());
7260 for (intptr_t i = 0; i < aliased_set_->max_place_id(); i++) { 7256 for (intptr_t i = 0; i < aliased_set_->max_place_id(); i++) {
7261 out->Add(NULL); 7257 out->Add(NULL);
(...skipping 2595 matching lines...) Expand 10 before | Expand all | Expand 10 after
9857 } 9853 }
9858 9854
9859 // Insert materializations at environment uses. 9855 // Insert materializations at environment uses.
9860 for (intptr_t i = 0; i < exits.length(); i++) { 9856 for (intptr_t i = 0; i < exits.length(); i++) {
9861 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *slots); 9857 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *slots);
9862 } 9858 }
9863 } 9859 }
9864 9860
9865 9861
9866 } // namespace dart 9862 } // namespace dart
OLDNEW
« runtime/vm/compiler.cc ('K') | « runtime/vm/compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698