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

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

Issue 1679853002: VM: Move redundancy elimination phases into a separate file. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fixed indentation Created 4 years, 10 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
« no previous file with comments | « runtime/vm/flow_graph.h ('k') | runtime/vm/flow_graph_optimizer.h » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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.h" 5 #include "vm/flow_graph.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/flow_graph_builder.h" 8 #include "vm/flow_graph_builder.h"
9 #include "vm/il_printer.h" 9 #include "vm/il_printer.h"
10 #include "vm/intermediate_language.h" 10 #include "vm/intermediate_language.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 loop_invariant_loads_(NULL), 45 loop_invariant_loads_(NULL),
46 guarded_fields_(parsed_function.guarded_fields()), 46 guarded_fields_(parsed_function.guarded_fields()),
47 deoptimize_dependent_code_(), 47 deoptimize_dependent_code_(),
48 deferred_prefixes_(parsed_function.deferred_prefixes()), 48 deferred_prefixes_(parsed_function.deferred_prefixes()),
49 captured_parameters_(new(zone()) BitVector(zone(), variable_count())), 49 captured_parameters_(new(zone()) BitVector(zone(), variable_count())),
50 inlining_id_(-1) { 50 inlining_id_(-1) {
51 DiscoverBlocks(); 51 DiscoverBlocks();
52 } 52 }
53 53
54 54
55 void FlowGraph::EnsureSSATempIndex(Definition* defn,
56 Definition* replacement) {
57 if ((replacement->ssa_temp_index() == -1) &&
58 (defn->ssa_temp_index() != -1)) {
59 AllocateSSAIndexes(replacement);
60 }
61 }
62
63
64 void FlowGraph::ReplaceCurrentInstruction(ForwardInstructionIterator* iterator,
65 Instruction* current,
66 Instruction* replacement) {
67 Definition* current_defn = current->AsDefinition();
68 if ((replacement != NULL) && (current_defn != NULL)) {
69 Definition* replacement_defn = replacement->AsDefinition();
70 ASSERT(replacement_defn != NULL);
71 current_defn->ReplaceUsesWith(replacement_defn);
72 EnsureSSATempIndex(current_defn, replacement_defn);
73
74 if (FLAG_trace_optimization) {
75 THR_Print("Replacing v%" Pd " with v%" Pd "\n",
76 current_defn->ssa_temp_index(),
77 replacement_defn->ssa_temp_index());
78 }
79 } else if (FLAG_trace_optimization) {
80 if (current_defn == NULL) {
81 THR_Print("Removing %s\n", current->DebugName());
82 } else {
83 ASSERT(!current_defn->HasUses());
84 THR_Print("Removing v%" Pd ".\n", current_defn->ssa_temp_index());
85 }
86 }
87 iterator->RemoveCurrentFromGraph();
88 }
89
90
91
55 void FlowGraph::AddToGuardedFields( 92 void FlowGraph::AddToGuardedFields(
56 ZoneGrowableArray<const Field*>* array, 93 ZoneGrowableArray<const Field*>* array,
57 const Field* field) { 94 const Field* field) {
58 if ((field->guarded_cid() == kDynamicCid) || 95 if ((field->guarded_cid() == kDynamicCid) ||
59 (field->guarded_cid() == kIllegalCid)) { 96 (field->guarded_cid() == kIllegalCid)) {
60 return; 97 return;
61 } 98 }
62 for (intptr_t j = 0; j < array->length(); j++) { 99 for (intptr_t j = 0; j < array->length(); j++) {
63 if ((*array)[j]->raw() == field->raw()) { 100 if ((*array)[j]->raw() == field->raw()) {
64 return; 101 return;
(...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 } 1428 }
1392 1429
1393 1430
1394 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, 1431 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from,
1395 BlockEntryInstr* to) const { 1432 BlockEntryInstr* to) const {
1396 return available_at_[to->postorder_number()]->Contains( 1433 return available_at_[to->postorder_number()]->Contains(
1397 from->postorder_number()); 1434 from->postorder_number());
1398 } 1435 }
1399 1436
1400 } // namespace dart 1437 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph.h ('k') | runtime/vm/flow_graph_optimizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698