| OLD | NEW |
| 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/longjump.h" | 10 #include "vm/longjump.h" |
| 11 #include "vm/growable_array.h" | 11 #include "vm/growable_array.h" |
| 12 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 DECLARE_FLAG(bool, reorder_basic_blocks); |
| 15 DECLARE_FLAG(bool, trace_optimization); | 16 DECLARE_FLAG(bool, trace_optimization); |
| 16 DECLARE_FLAG(bool, verify_compiler); | 17 DECLARE_FLAG(bool, verify_compiler); |
| 17 DEFINE_FLAG(bool, optimize_try_catch, true, "Optimization of try-catch"); | 18 DEFINE_FLAG(bool, optimize_try_catch, true, "Optimization of try-catch"); |
| 18 | 19 |
| 19 | 20 |
| 20 FlowGraph::FlowGraph(const FlowGraphBuilder& builder, | 21 FlowGraph::FlowGraph(const FlowGraphBuilder& builder, |
| 21 GraphEntryInstr* graph_entry, | 22 GraphEntryInstr* graph_entry, |
| 22 intptr_t max_block_id) | 23 intptr_t max_block_id) |
| 23 : parent_(), | 24 : parent_(), |
| 24 current_ssa_temp_index_(0), | 25 current_ssa_temp_index_(0), |
| 25 max_block_id_(max_block_id), | 26 max_block_id_(max_block_id), |
| 26 parsed_function_(*builder.parsed_function()), | 27 parsed_function_(*builder.parsed_function()), |
| 27 num_copied_params_(builder.num_copied_params()), | 28 num_copied_params_(builder.num_copied_params()), |
| 28 num_non_copied_params_(builder.num_non_copied_params()), | 29 num_non_copied_params_(builder.num_non_copied_params()), |
| 29 num_stack_locals_(builder.num_stack_locals()), | 30 num_stack_locals_(builder.num_stack_locals()), |
| 30 graph_entry_(graph_entry), | 31 graph_entry_(graph_entry), |
| 31 preorder_(), | 32 preorder_(), |
| 32 postorder_(), | 33 postorder_(), |
| 33 reverse_postorder_(), | 34 reverse_postorder_(), |
| 34 optimized_block_order_(), | 35 optimized_block_order_(), |
| 35 block_effects_(NULL), | 36 block_effects_(NULL), |
| 36 licm_allowed_(true), | 37 licm_allowed_(true), |
| 37 use_far_branches_(false), | 38 use_far_branches_(false), |
| 38 loop_headers_(NULL), | 39 loop_headers_(NULL), |
| 39 loop_invariant_loads_(NULL) { | 40 loop_invariant_loads_(NULL) { |
| 40 DiscoverBlocks(); | 41 DiscoverBlocks(); |
| 41 } | 42 } |
| 42 | 43 |
| 43 | 44 |
| 45 GrowableArray<BlockEntryInstr*>* FlowGraph::codegen_block_order( |
| 46 bool is_optimized) { |
| 47 return (is_optimized && FLAG_reorder_basic_blocks) |
| 48 ? &optimized_block_order_ |
| 49 : &reverse_postorder_; |
| 50 } |
| 51 |
| 52 |
| 44 ConstantInstr* FlowGraph::GetConstant(const Object& object) { | 53 ConstantInstr* FlowGraph::GetConstant(const Object& object) { |
| 45 // Check if the constant is already in the pool. | 54 // Check if the constant is already in the pool. |
| 46 GrowableArray<Definition*>* pool = graph_entry_->initial_definitions(); | 55 GrowableArray<Definition*>* pool = graph_entry_->initial_definitions(); |
| 47 for (intptr_t i = 0; i < pool->length(); ++i) { | 56 for (intptr_t i = 0; i < pool->length(); ++i) { |
| 48 ConstantInstr* constant = (*pool)[i]->AsConstant(); | 57 ConstantInstr* constant = (*pool)[i]->AsConstant(); |
| 49 if ((constant != NULL) && (constant->value().raw() == object.raw())) { | 58 if ((constant != NULL) && (constant->value().raw() == object.raw())) { |
| 50 return constant; | 59 return constant; |
| 51 } | 60 } |
| 52 } | 61 } |
| 53 // Otherwise, allocate and add it to the pool. | 62 // Otherwise, allocate and add it to the pool. |
| (...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 } | 1154 } |
| 1146 | 1155 |
| 1147 | 1156 |
| 1148 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, | 1157 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, |
| 1149 BlockEntryInstr* to) const { | 1158 BlockEntryInstr* to) const { |
| 1150 return available_at_[to->postorder_number()]->Contains( | 1159 return available_at_[to->postorder_number()]->Contains( |
| 1151 from->postorder_number()); | 1160 from->postorder_number()); |
| 1152 } | 1161 } |
| 1153 | 1162 |
| 1154 } // namespace dart | 1163 } // namespace dart |
| OLD | NEW |