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

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

Issue 14135006: Reapply "Incrementally recompute dominators when inlining." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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
« no previous file with comments | « runtime/vm/flow_graph.h ('k') | runtime/vm/flow_graph_builder.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/intermediate_language.h" 9 #include "vm/intermediate_language.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 11 matching lines...) Expand all
22 assigned_vars_(), 22 assigned_vars_(),
23 current_ssa_temp_index_(0), 23 current_ssa_temp_index_(0),
24 max_block_id_(max_block_id), 24 max_block_id_(max_block_id),
25 parsed_function_(builder.parsed_function()), 25 parsed_function_(builder.parsed_function()),
26 num_copied_params_(builder.num_copied_params()), 26 num_copied_params_(builder.num_copied_params()),
27 num_non_copied_params_(builder.num_non_copied_params()), 27 num_non_copied_params_(builder.num_non_copied_params()),
28 num_stack_locals_(builder.num_stack_locals()), 28 num_stack_locals_(builder.num_stack_locals()),
29 graph_entry_(graph_entry), 29 graph_entry_(graph_entry),
30 preorder_(), 30 preorder_(),
31 postorder_(), 31 postorder_(),
32 reverse_postorder_(), 32 reverse_postorder_() {
33 invalid_dominator_tree_(true) {
34 DiscoverBlocks(); 33 DiscoverBlocks();
35 } 34 }
36 35
37 36
38 ConstantInstr* FlowGraph::AddConstantToInitialDefinitions( 37 ConstantInstr* FlowGraph::AddConstantToInitialDefinitions(
39 const Object& object) { 38 const Object& object) {
40 // Check if the constant is already in the pool. 39 // Check if the constant is already in the pool.
41 for (intptr_t i = 0; i < graph_entry_->initial_definitions()->length(); ++i) { 40 for (intptr_t i = 0; i < graph_entry_->initial_definitions()->length(); ++i) {
42 ConstantInstr* constant = 41 ConstantInstr* constant =
43 (*graph_entry_->initial_definitions())[i]->AsConstant(); 42 (*graph_entry_->initial_definitions())[i]->AsConstant();
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 223
225 // Compute immediate dominators and the dominance frontier for each basic 224 // Compute immediate dominators and the dominance frontier for each basic
226 // block. As a side effect of the algorithm, sets the immediate dominator 225 // block. As a side effect of the algorithm, sets the immediate dominator
227 // of each basic block. 226 // of each basic block.
228 // 227 //
229 // dominance_frontier: an output parameter encoding the dominance frontier. 228 // dominance_frontier: an output parameter encoding the dominance frontier.
230 // The array maps the preorder block number of a block to the set of 229 // The array maps the preorder block number of a block to the set of
231 // (preorder block numbers of) blocks in the dominance frontier. 230 // (preorder block numbers of) blocks in the dominance frontier.
232 void FlowGraph::ComputeDominators( 231 void FlowGraph::ComputeDominators(
233 GrowableArray<BitVector*>* dominance_frontier) { 232 GrowableArray<BitVector*>* dominance_frontier) {
234 invalid_dominator_tree_ = false;
235 // Use the SEMI-NCA algorithm to compute dominators. This is a two-pass 233 // Use the SEMI-NCA algorithm to compute dominators. This is a two-pass
236 // version of the Lengauer-Tarjan algorithm (LT is normally three passes) 234 // version of the Lengauer-Tarjan algorithm (LT is normally three passes)
237 // that eliminates a pass by using nearest-common ancestor (NCA) to 235 // that eliminates a pass by using nearest-common ancestor (NCA) to
238 // compute immediate dominators from semidominators. It also removes a 236 // compute immediate dominators from semidominators. It also removes a
239 // level of indirection in the link-eval forest data structure. 237 // level of indirection in the link-eval forest data structure.
240 // 238 //
241 // The algorithm is described in Georgiadis, Tarjan, and Werneck's 239 // The algorithm is described in Georgiadis, Tarjan, and Werneck's
242 // "Finding Dominators in Practice". 240 // "Finding Dominators in Practice".
243 // See http://www.cs.princeton.edu/~rwerneck/dominators/ . 241 // See http://www.cs.princeton.edu/~rwerneck/dominators/ .
244 242
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 const char* function_name = parsed_function_.function().ToCString(); 664 const char* function_name = parsed_function_.function().ToCString();
667 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 665 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
668 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 666 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
669 OS::SNPrint(chars, len, kFormat, function_name, reason); 667 OS::SNPrint(chars, len, kFormat, function_name, reason);
670 const Error& error = Error::Handle( 668 const Error& error = Error::Handle(
671 LanguageError::New(String::Handle(String::New(chars)))); 669 LanguageError::New(String::Handle(String::New(chars))));
672 Isolate::Current()->long_jump_base()->Jump(1, error); 670 Isolate::Current()->long_jump_base()->Jump(1, error);
673 } 671 }
674 672
675 673
676 void FlowGraph::RepairGraphAfterInlining() {
677 DiscoverBlocks();
678 if (invalid_dominator_tree_) {
679 GrowableArray<BitVector*> dominance_frontier;
680 ComputeDominators(&dominance_frontier);
681 }
682 }
683
684
685 intptr_t FlowGraph::InstructionCount() const { 674 intptr_t FlowGraph::InstructionCount() const {
686 intptr_t size = 0; 675 intptr_t size = 0;
687 // Iterate each block, skipping the graph entry. 676 // Iterate each block, skipping the graph entry.
688 for (intptr_t i = 1; i < preorder_.length(); ++i) { 677 for (intptr_t i = 1; i < preorder_.length(); ++i) {
689 for (ForwardInstructionIterator it(preorder_[i]); 678 for (ForwardInstructionIterator it(preorder_[i]);
690 !it.Done(); 679 !it.Done();
691 it.Advance()) { 680 it.Advance()) {
692 ++size; 681 ++size;
693 } 682 }
694 } 683 }
695 return size; 684 return size;
696 } 685 }
697 686
698 } // namespace dart 687 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph.h ('k') | runtime/vm/flow_graph_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698