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

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

Issue 16693006: Initial implementation of on-stack replacement (OSR). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Clean up for review. Created 7 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
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 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 } 644 }
645 } 645 }
646 } 646 }
647 } 647 }
648 } 648 }
649 649
650 650
651 void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis, 651 void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis,
652 VariableLivenessAnalysis* variable_liveness, 652 VariableLivenessAnalysis* variable_liveness,
653 ZoneGrowableArray<Definition*>* inlining_parameters) { 653 ZoneGrowableArray<Definition*>* inlining_parameters) {
654 if (!FLAG_optimize_try_catch && (graph_entry_->SuccessorCount() > 1)) { 654 GraphEntryInstr* entry = graph_entry();
655 if (!FLAG_optimize_try_catch && (entry->SuccessorCount() > 1)) {
655 Bailout("Catch-entry support in SSA."); 656 Bailout("Catch-entry support in SSA.");
656 } 657 }
657 658
658 // Initial renaming environment. 659 // Initial renaming environment.
659 GrowableArray<Definition*> env(variable_count()); 660 GrowableArray<Definition*> env(variable_count());
660 661
661 // Add global constants to the initial definitions. 662 // Add global constants to the initial definitions.
662 constant_null_ = GetConstant(Object::ZoneHandle()); 663 constant_null_ = GetConstant(Object::ZoneHandle());
663 664
664 // Add parameters to the initial definitions and renaming environment. 665 // Add parameters to the initial definitions and renaming environment.
665 if (inlining_parameters != NULL) { 666 if (inlining_parameters != NULL) {
666 // Use known parameters. 667 // Use known parameters.
667 ASSERT(parameter_count() == inlining_parameters->length()); 668 ASSERT(parameter_count() == inlining_parameters->length());
668 for (intptr_t i = 0; i < parameter_count(); ++i) { 669 for (intptr_t i = 0; i < parameter_count(); ++i) {
669 Definition* defn = (*inlining_parameters)[i]; 670 Definition* defn = (*inlining_parameters)[i];
670 defn->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. 671 defn->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp.
671 AddToInitialDefinitions(defn); 672 AddToInitialDefinitions(defn);
672 env.Add(defn); 673 env.Add(defn);
673 } 674 }
674 } else { 675 } else {
675 // Create new parameters. 676 // Create new parameters. For functions compiled for OSR, the locals
676 for (intptr_t i = 0; i < parameter_count(); ++i) { 677 // are unknown and so treated like parameters.
677 ParameterInstr* param = new ParameterInstr(i, graph_entry_); 678 intptr_t count = IsCompiledForOsr() ? variable_count() : parameter_count();
679 for (intptr_t i = 0; i < count; ++i) {
680 ParameterInstr* param = new ParameterInstr(i, entry);
678 param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. 681 param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp.
679 AddToInitialDefinitions(param); 682 AddToInitialDefinitions(param);
680 env.Add(param); 683 env.Add(param);
681 } 684 }
682 } 685 }
683 686
684 // Initialize all locals with #null in the renaming environment. 687 // Initialize all locals with #null in the renaming environment. For OSR,
685 for (intptr_t i = parameter_count(); i < variable_count(); ++i) { 688 // the locals have already been handled as parameters.
686 env.Add(constant_null()); 689 if (!IsCompiledForOsr()) {
690 for (intptr_t i = parameter_count(); i < variable_count(); ++i) {
691 env.Add(constant_null());
692 }
687 } 693 }
688 694
689 if (graph_entry_->SuccessorCount() > 1) { 695 if (entry->SuccessorCount() > 1) {
690 // Functions with try-catch have a fixed area of stack slots reserved 696 // Functions with try-catch have a fixed area of stack slots reserved
691 // so that all local variables are stored at a known location when 697 // so that all local variables are stored at a known location when
692 // on entry to the catch. 698 // on entry to the catch.
693 graph_entry_->set_fixed_slot_count( 699 entry->set_fixed_slot_count(num_stack_locals() + num_copied_params());
694 num_stack_locals() + num_copied_params());
695 } 700 }
696 RenameRecursive(graph_entry_, &env, live_phis, variable_liveness); 701 RenameRecursive(entry, &env, live_phis, variable_liveness);
697 } 702 }
698 703
699 704
700 void FlowGraph::AttachEnvironment(Instruction* instr, 705 void FlowGraph::AttachEnvironment(Instruction* instr,
701 GrowableArray<Definition*>* env) { 706 GrowableArray<Definition*>* env) {
702 Environment* deopt_env = 707 Environment* deopt_env =
703 Environment::From(*env, 708 Environment::From(*env,
704 num_non_copied_params_, 709 num_non_copied_params_,
705 parsed_function_.function()); 710 parsed_function_.function());
706 instr->SetEnvironment(deopt_env); 711 instr->SetEnvironment(deopt_env);
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 } 1140 }
1136 1141
1137 1142
1138 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, 1143 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from,
1139 BlockEntryInstr* to) const { 1144 BlockEntryInstr* to) const {
1140 return available_at_[to->postorder_number()]->Contains( 1145 return available_at_[to->postorder_number()]->Contains(
1141 from->postorder_number()); 1146 from->postorder_number());
1142 } 1147 }
1143 1148
1144 } // namespace dart 1149 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698