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

Side by Side Diff: vm/flow_graph_builder.cc

Issue 10568007: Fix bailout from the optimizing-mode compiler and put SSA construction under a flag. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 6 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 | « vm/compiler.cc ('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_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"
11 #include "vm/flags.h" 11 #include "vm/flags.h"
12 #include "vm/il_printer.h" 12 #include "vm/il_printer.h"
13 #include "vm/intermediate_language.h" 13 #include "vm/intermediate_language.h"
14 #include "vm/longjump.h" 14 #include "vm/longjump.h"
15 #include "vm/object_store.h" 15 #include "vm/object_store.h"
16 #include "vm/os.h" 16 #include "vm/os.h"
17 #include "vm/parser.h" 17 #include "vm/parser.h"
18 #include "vm/resolver.h" 18 #include "vm/resolver.h"
19 #include "vm/stub_code.h" 19 #include "vm/stub_code.h"
20 20
21 namespace dart { 21 namespace dart {
22 22
23 DEFINE_FLAG(bool, eliminate_type_checks, true, 23 DEFINE_FLAG(bool, eliminate_type_checks, true,
24 "Eliminate type checks when allowed by static type analysis"); 24 "Eliminate type checks when allowed by static type analysis");
25 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); 25 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree.");
26 DEFINE_FLAG(bool, print_flow_graph, false, "Print the IR flow graph."); 26 DEFINE_FLAG(bool, print_flow_graph, false, "Print the IR flow graph.");
27 DEFINE_FLAG(bool, use_ssa, false, "Use SSA form");
27 DECLARE_FLAG(bool, enable_type_checks); 28 DECLARE_FLAG(bool, enable_type_checks);
28 29
29 30
30 FlowGraphBuilder::FlowGraphBuilder(const ParsedFunction& parsed_function) 31 FlowGraphBuilder::FlowGraphBuilder(const ParsedFunction& parsed_function)
31 : parsed_function_(parsed_function), 32 : parsed_function_(parsed_function),
32 preorder_block_entries_(), 33 preorder_block_entries_(),
33 postorder_block_entries_(), 34 postorder_block_entries_(),
34 context_level_(0), 35 context_level_(0),
35 last_used_try_index_(CatchClauseNode::kInvalidTryIndex), 36 last_used_try_index_(CatchClauseNode::kInvalidTryIndex),
36 try_index_(CatchClauseNode::kInvalidTryIndex), 37 try_index_(CatchClauseNode::kInvalidTryIndex),
(...skipping 2296 matching lines...) Expand 10 before | Expand all | Expand 10 after
2333 &preorder_block_entries_, 2334 &preorder_block_entries_,
2334 &postorder_block_entries_, 2335 &postorder_block_entries_,
2335 &parent, 2336 &parent,
2336 &assigned_vars, 2337 &assigned_vars,
2337 variable_count); 2338 variable_count);
2338 // Number blocks in reverse postorder. 2339 // Number blocks in reverse postorder.
2339 intptr_t block_count = postorder_block_entries_.length(); 2340 intptr_t block_count = postorder_block_entries_.length();
2340 for (intptr_t i = 0; i < block_count; ++i) { 2341 for (intptr_t i = 0; i < block_count; ++i) {
2341 postorder_block_entries_[i]->set_block_id(block_count - i - 1); 2342 postorder_block_entries_[i]->set_block_id(block_count - i - 1);
2342 } 2343 }
2343 if (for_optimized) { 2344 if (for_optimized && FLAG_use_ssa) {
2344 GrowableArray<BitVector*> dominance_frontier; 2345 GrowableArray<BitVector*> dominance_frontier;
2345 ComputeDominators(&preorder_block_entries_, &parent, &dominance_frontier); 2346 ComputeDominators(&preorder_block_entries_, &parent, &dominance_frontier);
2346 InsertPhis(preorder_block_entries_, 2347 InsertPhis(preorder_block_entries_,
2347 assigned_vars, 2348 assigned_vars,
2348 variable_count, 2349 variable_count,
2349 dominance_frontier); 2350 dominance_frontier);
2350 // TODO(fschneider): Perform SSA renaming. 2351 // TODO(fschneider): Perform SSA renaming.
2351 } 2352 }
2352 if (FLAG_print_flow_graph || (Dart::flow_graph_writer() != NULL)) { 2353 if (FLAG_print_flow_graph || (Dart::flow_graph_writer() != NULL)) {
2353 intptr_t length = postorder_block_entries_.length(); 2354 intptr_t length = postorder_block_entries_.length();
2354 GrowableArray<BlockEntryInstr*> reverse_postorder(length); 2355 GrowableArray<BlockEntryInstr*> reverse_postorder(length);
2355 for (intptr_t i = length - 1; i >= 0; --i) { 2356 for (intptr_t i = length - 1; i >= 0; --i) {
2356 reverse_postorder.Add(postorder_block_entries_[i]); 2357 reverse_postorder.Add(postorder_block_entries_[i]);
2357 } 2358 }
2358 if (FLAG_print_flow_graph) { 2359 if (FLAG_print_flow_graph) {
2359 // Print flow graph to stdout. 2360 // Print flow graph to stdout.
2360 FlowGraphPrinter printer(function, reverse_postorder); 2361 FlowGraphPrinter printer(function, reverse_postorder);
2361 printer.PrintBlocks(); 2362 printer.PrintBlocks();
2362 } 2363 }
2363 if (Dart::flow_graph_writer() != NULL) { 2364 if (Dart::flow_graph_writer() != NULL) {
2364 // Write flow graph to file. 2365 // Write flow graph to file.
2365 FlowGraphVisualizer printer(function, reverse_postorder); 2366 FlowGraphVisualizer printer(function, reverse_postorder);
2366 printer.PrintFunction(); 2367 printer.PrintFunction();
2367 } 2368 }
2368 } 2369 }
2370
2371 if (for_optimized && FLAG_use_ssa) {
2372 Bailout("No SSA code generation support.");
2373 }
2369 } 2374 }
2370 2375
2371 2376
2372 // Compute immediate dominators and the dominance frontier for each basic 2377 // Compute immediate dominators and the dominance frontier for each basic
2373 // block. As a side effect of the algorithm, sets the immediate dominator 2378 // block. As a side effect of the algorithm, sets the immediate dominator
2374 // of each basic block. 2379 // of each basic block.
2375 // 2380 //
2376 // preorder: an input list of basic block entries in preorder. The 2381 // preorder: an input list of basic block entries in preorder. The
2377 // algorithm relies on the block ordering. 2382 // algorithm relies on the block ordering.
2378 // 2383 //
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
2556 char* chars = reinterpret_cast<char*>( 2561 char* chars = reinterpret_cast<char*>(
2557 Isolate::Current()->current_zone()->Allocate(len)); 2562 Isolate::Current()->current_zone()->Allocate(len));
2558 OS::SNPrint(chars, len, kFormat, function_name, reason); 2563 OS::SNPrint(chars, len, kFormat, function_name, reason);
2559 const Error& error = Error::Handle( 2564 const Error& error = Error::Handle(
2560 LanguageError::New(String::Handle(String::New(chars)))); 2565 LanguageError::New(String::Handle(String::New(chars))));
2561 Isolate::Current()->long_jump_base()->Jump(1, error); 2566 Isolate::Current()->long_jump_base()->Jump(1, error);
2562 } 2567 }
2563 2568
2564 2569
2565 } // namespace dart 2570 } // namespace dart
OLDNEW
« no previous file with comments | « vm/compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698