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

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

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