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

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

Issue 10824147: Added support for copied parameters to the SSA compiler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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_builder.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_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 2241 matching lines...) Expand 10 before | Expand all | Expand 10 after
2252 TargetEntryInstr* normal_entry = new TargetEntryInstr(); 2252 TargetEntryInstr* normal_entry = new TargetEntryInstr();
2253 graph_entry_ = new GraphEntryInstr(normal_entry); 2253 graph_entry_ = new GraphEntryInstr(normal_entry);
2254 EffectGraphVisitor for_effect(this, 0); 2254 EffectGraphVisitor for_effect(this, 0);
2255 parsed_function().node_sequence()->Visit(&for_effect); 2255 parsed_function().node_sequence()->Visit(&for_effect);
2256 AppendFragment(normal_entry, for_effect); 2256 AppendFragment(normal_entry, for_effect);
2257 // Check that the graph is properly terminated. 2257 // Check that the graph is properly terminated.
2258 ASSERT(!for_effect.is_open()); 2258 ASSERT(!for_effect.is_open());
2259 GrowableArray<intptr_t> parent; 2259 GrowableArray<intptr_t> parent;
2260 GrowableArray<BitVector*> assigned_vars; 2260 GrowableArray<BitVector*> assigned_vars;
2261 2261
2262 const intptr_t fixed_parameter_count = 2262 // Either all parameters are fixed or (ie, one is named) they are all copied.
Florian Schneider 2012/08/02 14:44:39 s/one/none/
Florian Schneider 2012/08/02 14:45:59 Actually I'd write: Either all parameters are fix
zerny-google 2012/08/02 14:50:35 Done.
2263 parsed_function_.function().num_fixed_parameters(); 2263 // This could change, so we keep fixed/named counts separate.
2264 const intptr_t variable_count = fixed_parameter_count + 2264 intptr_t fixed_parameter_count;
2265 parsed_function_.copied_parameter_count() + 2265 intptr_t named_parameter_count;
2266 parsed_function_.stack_local_count(); 2266 if (parsed_function_.copied_parameter_count() > 0) {
2267 fixed_parameter_count = 0;
2268 named_parameter_count = parsed_function_.copied_parameter_count();
2269 } else {
2270 fixed_parameter_count = parsed_function_.function().num_fixed_parameters();
2271 named_parameter_count = 0;
2272 }
2273 const intptr_t stack_local_count = parsed_function_.stack_local_count();
2274 const intptr_t variable_count =
2275 stack_local_count + fixed_parameter_count + named_parameter_count;
2276
2267 // Perform a depth-first traversal of the graph to build preorder and 2277 // Perform a depth-first traversal of the graph to build preorder and
2268 // postorder block orders. 2278 // postorder block orders.
2269 graph_entry_->DiscoverBlocks(NULL, // Entry block predecessor. 2279 graph_entry_->DiscoverBlocks(NULL, // Entry block predecessor.
2270 &preorder_block_entries_, 2280 &preorder_block_entries_,
2271 &postorder_block_entries_, 2281 &postorder_block_entries_,
2272 &parent, 2282 &parent,
2273 &assigned_vars, 2283 &assigned_vars,
2274 variable_count, 2284 variable_count,
2275 fixed_parameter_count); 2285 fixed_parameter_count);
2276 // Number blocks in reverse postorder. 2286 // Number blocks in reverse postorder.
(...skipping 15 matching lines...) Expand all
2292 } 2302 }
2293 } 2303 }
2294 2304
2295 if (for_optimized && use_ssa) { 2305 if (for_optimized && use_ssa) {
2296 GrowableArray<BitVector*> dominance_frontier; 2306 GrowableArray<BitVector*> dominance_frontier;
2297 ComputeDominators(&preorder_block_entries_, &parent, &dominance_frontier); 2307 ComputeDominators(&preorder_block_entries_, &parent, &dominance_frontier);
2298 InsertPhis(preorder_block_entries_, 2308 InsertPhis(preorder_block_entries_,
2299 assigned_vars, 2309 assigned_vars,
2300 variable_count, 2310 variable_count,
2301 dominance_frontier); 2311 dominance_frontier);
2302 Rename(variable_count); 2312 Rename(stack_local_count, fixed_parameter_count, named_parameter_count);
2303 } 2313 }
2304 if (FLAG_print_flow_graph || (Dart::flow_graph_writer() != NULL)) { 2314 if (FLAG_print_flow_graph || (Dart::flow_graph_writer() != NULL)) {
2305 intptr_t length = postorder_block_entries_.length(); 2315 intptr_t length = postorder_block_entries_.length();
2306 GrowableArray<BlockEntryInstr*> reverse_postorder(length); 2316 GrowableArray<BlockEntryInstr*> reverse_postorder(length);
2307 for (intptr_t i = length - 1; i >= 0; --i) { 2317 for (intptr_t i = length - 1; i >= 0; --i) {
2308 reverse_postorder.Add(postorder_block_entries_[i]); 2318 reverse_postorder.Add(postorder_block_entries_[i]);
2309 } 2319 }
2310 if (FLAG_print_flow_graph) { 2320 if (FLAG_print_flow_graph) {
2311 // Print flow graph to stdout. 2321 // Print flow graph to stdout.
2312 FlowGraphPrinter printer(function, reverse_postorder); 2322 FlowGraphPrinter printer(function, reverse_postorder);
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2494 work[index] = var_index; 2504 work[index] = var_index;
2495 worklist.Add(block); 2505 worklist.Add(block);
2496 } 2506 }
2497 } 2507 }
2498 } 2508 }
2499 } 2509 }
2500 } 2510 }
2501 } 2511 }
2502 2512
2503 2513
2504 void FlowGraphBuilder::Rename(intptr_t var_count) { 2514 void FlowGraphBuilder::Rename(intptr_t stack_local_count,
2505 // TODO(fschneider): Store var_count in the FlowGraphBuilder instead of 2515 intptr_t fixed_parameter_count,
2516 intptr_t named_parameter_count) {
2517 // TODO(fschneider): Store counts in the FlowGraphBuilder instead of
2506 // passing it around. 2518 // passing it around.
2507 // TODO(fschneider): Support catch-entry. 2519 // TODO(fschneider): Support catch-entry.
2508 if (graph_entry_->SuccessorCount() > 1) { 2520 if (graph_entry_->SuccessorCount() > 1) {
2509 Bailout("Catch-entry support in SSA."); 2521 Bailout("Catch-entry support in SSA.");
2510 } 2522 }
2511 // TODO(fschneider): Support copied parameters. 2523
2512 if (parsed_function().copied_parameter_count() != 0) { 2524 const intptr_t parameter_count =
2513 Bailout("Copied parameter support in SSA"); 2525 named_parameter_count + fixed_parameter_count;
2514 } 2526 const intptr_t variable_count = parameter_count + stack_local_count;
2515 ASSERT(var_count == (parsed_function().stack_local_count() +
2516 parsed_function().function().num_fixed_parameters()));
2517 2527
2518 // Initialize start environment. 2528 // Initialize start environment.
2519 GrowableArray<Value*> start_env(var_count); 2529 GrowableArray<Value*> start_env(variable_count);
2520 intptr_t i = 0; 2530 intptr_t i = 0;
2521 const intptr_t fixed_parameter_count = 2531 for (; i < parameter_count; ++i) {
2522 parsed_function().function().num_fixed_parameters();
2523 for (; i < fixed_parameter_count; ++i) {
2524 ParameterInstr* param = new ParameterInstr(i); 2532 ParameterInstr* param = new ParameterInstr(i);
2525 param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. 2533 param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp.
2526 start_env.Add(new UseVal(param)); 2534 start_env.Add(new UseVal(param));
2527 } 2535 }
2528 2536
2529 // All locals are initialized with #null. 2537 // All locals are initialized with #null.
2530 Value* null_value = new ConstantVal(Object::ZoneHandle()); 2538 Value* null_value = new ConstantVal(Object::ZoneHandle());
2531 for (; i < var_count; i++) { 2539 for (; i < variable_count; i++) {
2532 start_env.Add(null_value); 2540 start_env.Add(null_value);
2533 } 2541 }
2534 graph_entry_->set_start_env( 2542 graph_entry_->set_start_env(
2535 new Environment(start_env, fixed_parameter_count)); 2543 new Environment(start_env, fixed_parameter_count));
2536 2544
2537 BlockEntryInstr* normal_entry = graph_entry_->SuccessorAt(0); 2545 BlockEntryInstr* normal_entry = graph_entry_->SuccessorAt(0);
2538 ASSERT(normal_entry != NULL); // Must have entry. 2546 ASSERT(normal_entry != NULL); // Must have entry.
2539 GrowableArray<Value*> env(var_count); 2547 GrowableArray<Value*> env(variable_count);
2540 env.AddArray(start_env); 2548 env.AddArray(start_env);
2541 RenameRecursive(normal_entry, &env, var_count, fixed_parameter_count); 2549 RenameRecursive(normal_entry, &env, variable_count, fixed_parameter_count);
2542 } 2550 }
2543 2551
2544 2552
2545 // Helper to a copy a value iff it is a UseVal. 2553 // Helper to a copy a value iff it is a UseVal.
2546 static Value* CopyValue(Value* value) { 2554 static Value* CopyValue(Value* value) {
2547 return value->IsUse() 2555 return value->IsUse()
2548 ? new UseVal(value->AsUse()->definition()) 2556 ? new UseVal(value->AsUse()->definition())
2549 : value; 2557 : value;
2550 } 2558 }
2551 2559
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2688 char* chars = reinterpret_cast<char*>( 2696 char* chars = reinterpret_cast<char*>(
2689 Isolate::Current()->current_zone()->Allocate(len)); 2697 Isolate::Current()->current_zone()->Allocate(len));
2690 OS::SNPrint(chars, len, kFormat, function_name, reason); 2698 OS::SNPrint(chars, len, kFormat, function_name, reason);
2691 const Error& error = Error::Handle( 2699 const Error& error = Error::Handle(
2692 LanguageError::New(String::Handle(String::New(chars)))); 2700 LanguageError::New(String::Handle(String::New(chars))));
2693 Isolate::Current()->long_jump_base()->Jump(1, error); 2701 Isolate::Current()->long_jump_base()->Jump(1, error);
2694 } 2702 }
2695 2703
2696 2704
2697 } // namespace dart 2705 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698