| 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_builder.h" | 5 #include "vm/flow_graph_builder.h" |
| 6 | 6 |
| 7 #include "vm/ast_printer.h" | 7 #include "vm/ast_printer.h" |
| 8 #include "vm/bit_vector.h" | 8 #include "vm/bit_vector.h" |
| 9 #include "vm/code_descriptors.h" | 9 #include "vm/code_descriptors.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 2113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2124 // Check that the graph is properly terminated. | 2124 // Check that the graph is properly terminated. |
| 2125 ASSERT(!for_effect.is_open()); | 2125 ASSERT(!for_effect.is_open()); |
| 2126 GrowableArray<intptr_t> parent; | 2126 GrowableArray<intptr_t> parent; |
| 2127 GrowableArray<BitVector*> assigned_vars; | 2127 GrowableArray<BitVector*> assigned_vars; |
| 2128 intptr_t variable_count = parsed_function_.function().num_fixed_parameters() + | 2128 intptr_t variable_count = parsed_function_.function().num_fixed_parameters() + |
| 2129 parsed_function_.copied_parameter_count() + | 2129 parsed_function_.copied_parameter_count() + |
| 2130 parsed_function_.stack_local_count(); | 2130 parsed_function_.stack_local_count(); |
| 2131 // Perform a depth-first traversal of the graph to build preorder and | 2131 // Perform a depth-first traversal of the graph to build preorder and |
| 2132 // postorder block orders. | 2132 // postorder block orders. |
| 2133 graph_entry_->DiscoverBlocks(NULL, // Entry block predecessor. | 2133 graph_entry_->DiscoverBlocks(NULL, // Entry block predecessor. |
| 2134 &preorder_block_entries_, | 2134 this, |
| 2135 &postorder_block_entries_, | |
| 2136 &parent, | 2135 &parent, |
| 2137 &assigned_vars, | 2136 &assigned_vars, |
| 2138 variable_count); | 2137 variable_count); |
| 2138 // Number blocks in reverse postorder. |
| 2139 intptr_t block_count = postorder_block_entries_.length(); |
| 2140 for (intptr_t i = 0; i < block_count; ++i) { |
| 2141 postorder_block_entries_[i]->set_block_id(block_count - i - 1); |
| 2142 } |
| 2139 if (for_optimized) { | 2143 if (for_optimized) { |
| 2140 GrowableArray<BitVector*> dominance_frontier; | 2144 GrowableArray<BitVector*> dominance_frontier; |
| 2141 ComputeDominators(&preorder_block_entries_, &parent, &dominance_frontier); | 2145 ComputeDominators(&preorder_block_entries_, &parent, &dominance_frontier); |
| 2142 } | 2146 } |
| 2143 isolate->set_computation_id(prev_cid); | 2147 isolate->set_computation_id(prev_cid); |
| 2144 if (FLAG_print_flow_graph) { | 2148 if (FLAG_print_flow_graph) { |
| 2145 intptr_t length = postorder_block_entries_.length(); | 2149 intptr_t length = postorder_block_entries_.length(); |
| 2146 GrowableArray<BlockEntryInstr*> reverse_postorder(length); | 2150 GrowableArray<BlockEntryInstr*> reverse_postorder(length); |
| 2147 for (intptr_t i = length - 1; i >= 0; --i) { | 2151 for (intptr_t i = length - 1; i >= 0; --i) { |
| 2148 reverse_postorder.Add(postorder_block_entries_[i]); | 2152 reverse_postorder.Add(postorder_block_entries_[i]); |
| 2149 } | 2153 } |
| 2150 FlowGraphPrinter printer(function, reverse_postorder); | 2154 FlowGraphPrinter printer(function, reverse_postorder); |
| 2151 printer.VisitBlocks(); | 2155 printer.PrintBlocks(); |
| 2152 } | 2156 } |
| 2153 } | 2157 } |
| 2154 | 2158 |
| 2155 | 2159 |
| 2156 // Compute immediate dominators and the dominance frontier for each basic | 2160 // Compute immediate dominators and the dominance frontier for each basic |
| 2157 // block. As a side effect of the algorithm, sets the immediate dominator | 2161 // block. As a side effect of the algorithm, sets the immediate dominator |
| 2158 // of each basic block. | 2162 // of each basic block. |
| 2159 // | 2163 // |
| 2160 // preorder: an input list of basic block entries in preorder. The | 2164 // preorder: an input list of basic block entries in preorder. The |
| 2161 // algorithm relies on the block ordering. | 2165 // algorithm relies on the block ordering. |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2283 char* chars = reinterpret_cast<char*>( | 2287 char* chars = reinterpret_cast<char*>( |
| 2284 Isolate::Current()->current_zone()->Allocate(len)); | 2288 Isolate::Current()->current_zone()->Allocate(len)); |
| 2285 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2289 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2286 const Error& error = Error::Handle( | 2290 const Error& error = Error::Handle( |
| 2287 LanguageError::New(String::Handle(String::New(chars)))); | 2291 LanguageError::New(String::Handle(String::New(chars)))); |
| 2288 Isolate::Current()->long_jump_base()->Jump(1, error); | 2292 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2289 } | 2293 } |
| 2290 | 2294 |
| 2291 | 2295 |
| 2292 } // namespace dart | 2296 } // namespace dart |
| OLD | NEW |