OLD | NEW |
---|---|
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 InsertAfter(next->previous(), instr, env, use_kind); | 108 InsertAfter(next->previous(), instr, env, use_kind); |
109 } | 109 } |
110 | 110 |
111 | 111 |
112 void FlowGraph::InsertAfter(Instruction* prev, | 112 void FlowGraph::InsertAfter(Instruction* prev, |
113 Instruction* instr, | 113 Instruction* instr, |
114 Environment* env, | 114 Environment* env, |
115 Definition::UseKind use_kind) { | 115 Definition::UseKind use_kind) { |
116 if (use_kind == Definition::kValue) { | 116 if (use_kind == Definition::kValue) { |
117 ASSERT(instr->IsDefinition()); | 117 ASSERT(instr->IsDefinition()); |
118 instr->AsDefinition()->set_ssa_temp_index(alloc_ssa_temp_index()); | 118 Definition* defn = instr->AsDefinition(); |
119 AllocateSSAIndexes(defn); | |
srdjan
2014/04/07 18:22:50
AllocateSSAIndexes(instr->AsDefinition()) .. also
Cutch
2014/04/08 15:56:16
Done here and elsewhere.
| |
119 } | 120 } |
120 instr->InsertAfter(prev); | 121 instr->InsertAfter(prev); |
121 ASSERT(instr->env() == NULL); | 122 ASSERT(instr->env() == NULL); |
122 if (env != NULL) env->DeepCopyTo(instr); | 123 if (env != NULL) env->DeepCopyTo(instr); |
123 } | 124 } |
124 | 125 |
125 | 126 |
126 Instruction* FlowGraph::AppendTo(Instruction* prev, | 127 Instruction* FlowGraph::AppendTo(Instruction* prev, |
127 Instruction* instr, | 128 Instruction* instr, |
128 Environment* env, | 129 Environment* env, |
129 Definition::UseKind use_kind) { | 130 Definition::UseKind use_kind) { |
130 if (use_kind == Definition::kValue) { | 131 if (use_kind == Definition::kValue) { |
131 ASSERT(instr->IsDefinition()); | 132 ASSERT(instr->IsDefinition()); |
132 instr->AsDefinition()->set_ssa_temp_index(alloc_ssa_temp_index()); | 133 Definition* defn = instr->AsDefinition(); |
134 AllocateSSAIndexes(defn); | |
133 } | 135 } |
134 ASSERT(instr->env() == NULL); | 136 ASSERT(instr->env() == NULL); |
135 if (env != NULL) env->DeepCopyTo(instr); | 137 if (env != NULL) env->DeepCopyTo(instr); |
136 return prev->AppendInstruction(instr); | 138 return prev->AppendInstruction(instr); |
137 } | 139 } |
138 | 140 |
139 | 141 |
140 void FlowGraph::DiscoverBlocks() { | 142 void FlowGraph::DiscoverBlocks() { |
141 // Initialize state. | 143 // Initialize state. |
142 preorder_.Clear(); | 144 preorder_.Clear(); |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
709 // Add global constants to the initial definitions. | 711 // Add global constants to the initial definitions. |
710 constant_null_ = GetConstant(Object::ZoneHandle()); | 712 constant_null_ = GetConstant(Object::ZoneHandle()); |
711 constant_dead_ = GetConstant(Symbols::OptimizedOut()); | 713 constant_dead_ = GetConstant(Symbols::OptimizedOut()); |
712 | 714 |
713 // Add parameters to the initial definitions and renaming environment. | 715 // Add parameters to the initial definitions and renaming environment. |
714 if (inlining_parameters != NULL) { | 716 if (inlining_parameters != NULL) { |
715 // Use known parameters. | 717 // Use known parameters. |
716 ASSERT(parameter_count() == inlining_parameters->length()); | 718 ASSERT(parameter_count() == inlining_parameters->length()); |
717 for (intptr_t i = 0; i < parameter_count(); ++i) { | 719 for (intptr_t i = 0; i < parameter_count(); ++i) { |
718 Definition* defn = (*inlining_parameters)[i]; | 720 Definition* defn = (*inlining_parameters)[i]; |
719 defn->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. | 721 AllocateSSAIndexes(defn); |
720 AddToInitialDefinitions(defn); | 722 AddToInitialDefinitions(defn); |
721 env.Add(defn); | 723 env.Add(defn); |
722 } | 724 } |
723 } else { | 725 } else { |
724 // Create new parameters. For functions compiled for OSR, the locals | 726 // Create new parameters. For functions compiled for OSR, the locals |
725 // are unknown and so treated like parameters. | 727 // are unknown and so treated like parameters. |
726 intptr_t count = IsCompiledForOsr() ? variable_count() : parameter_count(); | 728 intptr_t count = IsCompiledForOsr() ? variable_count() : parameter_count(); |
727 for (intptr_t i = 0; i < count; ++i) { | 729 for (intptr_t i = 0; i < count; ++i) { |
728 ParameterInstr* param = new ParameterInstr(i, entry); | 730 ParameterInstr* param = new ParameterInstr(i, entry); |
729 param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. | 731 param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
919 env->Add(result); | 921 env->Add(result); |
920 // We remove load/store/constant instructions when we find their | 922 // We remove load/store/constant instructions when we find their |
921 // use in 2a. | 923 // use in 2a. |
922 } else { | 924 } else { |
923 it.RemoveCurrentFromGraph(); | 925 it.RemoveCurrentFromGraph(); |
924 } | 926 } |
925 } else { | 927 } else { |
926 // Not a load, store, or constant. | 928 // Not a load, store, or constant. |
927 if (definition->is_used()) { | 929 if (definition->is_used()) { |
928 // Assign fresh SSA temporary and update expression stack. | 930 // Assign fresh SSA temporary and update expression stack. |
929 definition->set_ssa_temp_index(alloc_ssa_temp_index()); | 931 AllocateSSAIndexes(definition); |
930 env->Add(definition); | 932 env->Add(definition); |
931 } | 933 } |
932 } | 934 } |
933 } | 935 } |
934 | 936 |
935 // 2c. Handle pushed argument. | 937 // 2c. Handle pushed argument. |
936 PushArgumentInstr* push = current->AsPushArgument(); | 938 PushArgumentInstr* push = current->AsPushArgument(); |
937 if (push != NULL) { | 939 if (push != NULL) { |
938 env->Add(push); | 940 env->Add(push); |
939 } | 941 } |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1218 } | 1220 } |
1219 | 1221 |
1220 | 1222 |
1221 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, | 1223 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, |
1222 BlockEntryInstr* to) const { | 1224 BlockEntryInstr* to) const { |
1223 return available_at_[to->postorder_number()]->Contains( | 1225 return available_at_[to->postorder_number()]->Contains( |
1224 from->postorder_number()); | 1226 from->postorder_number()); |
1225 } | 1227 } |
1226 | 1228 |
1227 } // namespace dart | 1229 } // namespace dart |
OLD | NEW |