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

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

Issue 344883009: Use hash map for the SSA builder constant pool. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« runtime/vm/flow_graph.h ('K') | « runtime/vm/flow_graph.h ('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) 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/intermediate_language.h" 9 #include "vm/intermediate_language.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 GrowableArray<BlockEntryInstr*>* FlowGraph::CodegenBlockOrder( 87 GrowableArray<BlockEntryInstr*>* FlowGraph::CodegenBlockOrder(
88 bool is_optimized) { 88 bool is_optimized) {
89 return ShouldReorderBlocks(parsed_function().function(), is_optimized) 89 return ShouldReorderBlocks(parsed_function().function(), is_optimized)
90 ? &optimized_block_order_ 90 ? &optimized_block_order_
91 : &reverse_postorder_; 91 : &reverse_postorder_;
92 } 92 }
93 93
94 94
95 ConstantInstr* FlowGraph::GetConstant(const Object& object) { 95 ConstantInstr* FlowGraph::GetConstant(const Object& object) {
96 // Check if the constant is already in the pool. 96 ConstantInstr* constant = constant_instr_pool_.Lookup(object);
97 GrowableArray<Definition*>* pool = graph_entry_->initial_definitions(); 97 if (constant == NULL) {
98 for (intptr_t i = 0; i < pool->length(); ++i) { 98 // Otherwise, allocate and add it to the pool.
99 ConstantInstr* constant = (*pool)[i]->AsConstant(); 99 constant = new(isolate()) ConstantInstr(object);
100 if ((constant != NULL) && (constant->value().raw() == object.raw())) { 100 constant->set_ssa_temp_index(alloc_ssa_temp_index());
101 return constant; 101 AddToInitialDefinitions(constant);
102 } 102 constant_instr_pool_.Insert(constant);
103 } 103 }
104 // Otherwise, allocate and add it to the pool.
105 ConstantInstr* constant = new(isolate()) ConstantInstr(object);
106 constant->set_ssa_temp_index(alloc_ssa_temp_index());
107 AddToInitialDefinitions(constant);
108 return constant; 104 return constant;
109 } 105 }
110 106
111 107
112 void FlowGraph::AddToInitialDefinitions(Definition* defn) { 108 void FlowGraph::AddToInitialDefinitions(Definition* defn) {
113 // TODO(zerny): Set previous to the graph entry so it is accessible by 109 // TODO(zerny): Set previous to the graph entry so it is accessible by
114 // GetBlock. Remove this once there is a direct pointer to the block. 110 // GetBlock. Remove this once there is a direct pointer to the block.
115 defn->set_previous(graph_entry_); 111 defn->set_previous(graph_entry_);
116 graph_entry_->initial_definitions()->Add(defn); 112 graph_entry_->initial_definitions()->Add(defn);
117 } 113 }
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 } 1253 }
1258 1254
1259 1255
1260 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, 1256 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from,
1261 BlockEntryInstr* to) const { 1257 BlockEntryInstr* to) const {
1262 return available_at_[to->postorder_number()]->Contains( 1258 return available_at_[to->postorder_number()]->Contains(
1263 from->postorder_number()); 1259 from->postorder_number());
1264 } 1260 }
1265 1261
1266 } // namespace dart 1262 } // namespace dart
OLDNEW
« runtime/vm/flow_graph.h ('K') | « runtime/vm/flow_graph.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698