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

Side by Side Diff: vm/flow_graph_builder.cc

Issue 10735002: Add support for fixed parameters in SSA builder and fix a bug in the pre-order graph traversal. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 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 | « no previous file | vm/il_printer.cc » ('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_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 2595 matching lines...) Expand 10 before | Expand all | Expand 10 after
2606 worklist.Add(block); 2606 worklist.Add(block);
2607 } 2607 }
2608 } 2608 }
2609 } 2609 }
2610 } 2610 }
2611 } 2611 }
2612 } 2612 }
2613 2613
2614 2614
2615 void FlowGraphBuilder::Rename(intptr_t var_count) { 2615 void FlowGraphBuilder::Rename(intptr_t var_count) {
2616 // Initialize start environment:
2617 // All locals are initialized with #null.
2618 // TODO(fschneider): Support parameters. All parameters are initially located
2619 // on the stack.
2620 // TODO(fschneider): Store var_count in the FlowGraphBuilder instead of 2616 // TODO(fschneider): Store var_count in the FlowGraphBuilder instead of
2621 // passing it around. 2617 // passing it around.
2622 ZoneGrowableArray<Value*>* start_env = 2618 // TODO(fschneider): Support catch-entry.
2623 new ZoneGrowableArray<Value*>(var_count); 2619 if (graph_entry_->SuccessorCount() > 1) {
2624 if (parsed_function().function().num_fixed_parameters() > 0) { 2620 Bailout("Catch-entry support in SSA.");
2625 Bailout("Fixed parameter support in SSA");
2626 } 2621 }
2622 // TODO(fschneider): Support copied parameters.
2627 if (parsed_function().copied_parameter_count()) { 2623 if (parsed_function().copied_parameter_count()) {
2628 Bailout("Copied parameter support in SSA"); 2624 Bailout("Copied parameter support in SSA");
2629 } 2625 }
2626 ASSERT(var_count == (parsed_function().stack_local_count() +
2627 parsed_function().function().num_fixed_parameters()));
2628
2629 // Initialize start environment.
2630 ZoneGrowableArray<Value*>* start_env =
2631 new ZoneGrowableArray<Value*>(var_count);
2632 intptr_t i = 0;
2633 for (; i < parsed_function().function().num_fixed_parameters(); ++i) {
2634 ParameterInstr* param = new ParameterInstr(i);
2635 param->set_ssa_temp_index(current_ssa_temp_index_++); // New SSA temp.
2636 start_env->Add(new UseVal(param));
2637 }
2638
2639 // All locals are initialized with #null.
2630 Value* null_value = new ConstantVal(Object::ZoneHandle()); 2640 Value* null_value = new ConstantVal(Object::ZoneHandle());
2631 // TODO(fschneider): Change this assert once parameters are supported. 2641 for (; i < var_count; i++) {
2632 ASSERT(var_count == parsed_function().stack_local_count());
2633 for (intptr_t i = 0; i < var_count; i++) {
2634 start_env->Add(null_value); 2642 start_env->Add(null_value);
2635 } 2643 }
2636 graph_entry_->set_start_env(start_env); 2644 graph_entry_->set_start_env(new Environment(start_env));
2637 2645
2638 BlockEntryInstr* normal_entry = graph_entry_->SuccessorAt(0); 2646 BlockEntryInstr* normal_entry = graph_entry_->SuccessorAt(0);
2639 ASSERT(normal_entry != NULL); // Must have entry. 2647 ASSERT(normal_entry != NULL); // Must have entry.
2640 ZoneGrowableArray<Value*>* env = new ZoneGrowableArray<Value*>(var_count); 2648 ZoneGrowableArray<Value*>* env = new ZoneGrowableArray<Value*>(var_count);
2641 env->AddArray(*start_env); 2649 env->AddArray(*start_env);
2642 RenameRecursive(normal_entry, env, var_count); 2650 RenameRecursive(normal_entry, env, var_count);
2643 } 2651 }
2644 2652
2645 2653
2646 static intptr_t WhichPred(BlockEntryInstr* predecessor, 2654 static intptr_t WhichPred(BlockEntryInstr* predecessor,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2757 env->Add(new UseVal(current->AsDefinition())); 2765 env->Add(new UseVal(current->AsDefinition()));
2758 } 2766 }
2759 current = current->successor(); 2767 current = current->successor();
2760 } 2768 }
2761 } 2769 }
2762 2770
2763 // 3. Process dominated blocks. 2771 // 3. Process dominated blocks.
2764 for (intptr_t i = 0; i < block_entry->dominated_blocks().length(); ++i) { 2772 for (intptr_t i = 0; i < block_entry->dominated_blocks().length(); ++i) {
2765 BlockEntryInstr* block = block_entry->dominated_blocks()[i]; 2773 BlockEntryInstr* block = block_entry->dominated_blocks()[i];
2766 ZoneGrowableArray<Value*>* new_env = 2774 ZoneGrowableArray<Value*>* new_env =
2767 new ZoneGrowableArray<Value*>(var_count); 2775 new ZoneGrowableArray<Value*>(env->length());
2768 new_env->AddArray(*env); 2776 new_env->AddArray(*env);
2769 RenameRecursive(block, new_env, var_count); 2777 RenameRecursive(block, new_env, var_count);
2770 } 2778 }
2771 2779
2772 // 4. Process successor block. We have edge-split form, so that only blocks 2780 // 4. Process successor block. We have edge-split form, so that only blocks
2773 // with one successor can have a join block as successor. 2781 // with one successor can have a join block as successor.
2774 if ((block_entry->last_instruction()->SuccessorCount() == 1) && 2782 if ((block_entry->last_instruction()->SuccessorCount() == 1) &&
2775 block_entry->last_instruction()->SuccessorAt(0)->IsJoinEntry()) { 2783 block_entry->last_instruction()->SuccessorAt(0)->IsJoinEntry()) {
2776 JoinEntryInstr* successor = 2784 JoinEntryInstr* successor =
2777 block_entry->last_instruction()->SuccessorAt(0)->AsJoinEntry(); 2785 block_entry->last_instruction()->SuccessorAt(0)->AsJoinEntry();
(...skipping 21 matching lines...) Expand all
2799 char* chars = reinterpret_cast<char*>( 2807 char* chars = reinterpret_cast<char*>(
2800 Isolate::Current()->current_zone()->Allocate(len)); 2808 Isolate::Current()->current_zone()->Allocate(len));
2801 OS::SNPrint(chars, len, kFormat, function_name, reason); 2809 OS::SNPrint(chars, len, kFormat, function_name, reason);
2802 const Error& error = Error::Handle( 2810 const Error& error = Error::Handle(
2803 LanguageError::New(String::Handle(String::New(chars)))); 2811 LanguageError::New(String::Handle(String::New(chars))));
2804 Isolate::Current()->long_jump_base()->Jump(1, error); 2812 Isolate::Current()->long_jump_base()->Jump(1, error);
2805 } 2813 }
2806 2814
2807 2815
2808 } // namespace dart 2816 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | vm/il_printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698