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 defn->set_ssa_temp_index(alloc_ssa_temp_index()); | |
120 if (defn->RequiresTwoSSATempIndexes()) { | |
121 defn->set_ssa_temp_index2(alloc_ssa_temp_index()); | |
Vyacheslav Egorov (Google)
2014/04/03 18:10:09
I am not sure I like the naming here.
Cutch
2014/04/03 18:35:07
I've renamed it to pair_ssa_index. I don't really
| |
122 } | |
119 } | 123 } |
120 instr->InsertAfter(prev); | 124 instr->InsertAfter(prev); |
121 ASSERT(instr->env() == NULL); | 125 ASSERT(instr->env() == NULL); |
122 if (env != NULL) env->DeepCopyTo(instr); | 126 if (env != NULL) env->DeepCopyTo(instr); |
123 } | 127 } |
124 | 128 |
125 | 129 |
126 Instruction* FlowGraph::AppendTo(Instruction* prev, | 130 Instruction* FlowGraph::AppendTo(Instruction* prev, |
127 Instruction* instr, | 131 Instruction* instr, |
128 Environment* env, | 132 Environment* env, |
129 Definition::UseKind use_kind) { | 133 Definition::UseKind use_kind) { |
130 if (use_kind == Definition::kValue) { | 134 if (use_kind == Definition::kValue) { |
131 ASSERT(instr->IsDefinition()); | 135 ASSERT(instr->IsDefinition()); |
132 instr->AsDefinition()->set_ssa_temp_index(alloc_ssa_temp_index()); | 136 Definition* defn = instr->AsDefinition(); |
137 defn->set_ssa_temp_index(alloc_ssa_temp_index()); | |
138 if (defn->RequiresTwoSSATempIndexes()) { | |
Vyacheslav Egorov (Google)
2014/04/03 18:10:09
The code is duplicated in multiple places. I wonde
Cutch
2014/04/03 18:35:07
Done. Added the following to FlowGraph:
void Assi
| |
139 defn->set_ssa_temp_index2(alloc_ssa_temp_index()); | |
140 } | |
133 } | 141 } |
134 ASSERT(instr->env() == NULL); | 142 ASSERT(instr->env() == NULL); |
135 if (env != NULL) env->DeepCopyTo(instr); | 143 if (env != NULL) env->DeepCopyTo(instr); |
136 return prev->AppendInstruction(instr); | 144 return prev->AppendInstruction(instr); |
137 } | 145 } |
138 | 146 |
139 | 147 |
140 void FlowGraph::DiscoverBlocks() { | 148 void FlowGraph::DiscoverBlocks() { |
141 // Initialize state. | 149 // Initialize state. |
142 preorder_.Clear(); | 150 preorder_.Clear(); |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
710 constant_null_ = GetConstant(Object::ZoneHandle()); | 718 constant_null_ = GetConstant(Object::ZoneHandle()); |
711 constant_dead_ = GetConstant(Symbols::OptimizedOut()); | 719 constant_dead_ = GetConstant(Symbols::OptimizedOut()); |
712 | 720 |
713 // Add parameters to the initial definitions and renaming environment. | 721 // Add parameters to the initial definitions and renaming environment. |
714 if (inlining_parameters != NULL) { | 722 if (inlining_parameters != NULL) { |
715 // Use known parameters. | 723 // Use known parameters. |
716 ASSERT(parameter_count() == inlining_parameters->length()); | 724 ASSERT(parameter_count() == inlining_parameters->length()); |
717 for (intptr_t i = 0; i < parameter_count(); ++i) { | 725 for (intptr_t i = 0; i < parameter_count(); ++i) { |
718 Definition* defn = (*inlining_parameters)[i]; | 726 Definition* defn = (*inlining_parameters)[i]; |
719 defn->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. | 727 defn->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. |
728 if (defn->RequiresTwoSSATempIndexes()) { | |
729 defn->set_ssa_temp_index2(alloc_ssa_temp_index()); | |
730 } | |
720 AddToInitialDefinitions(defn); | 731 AddToInitialDefinitions(defn); |
721 env.Add(defn); | 732 env.Add(defn); |
722 } | 733 } |
723 } else { | 734 } else { |
724 // Create new parameters. For functions compiled for OSR, the locals | 735 // Create new parameters. For functions compiled for OSR, the locals |
725 // are unknown and so treated like parameters. | 736 // are unknown and so treated like parameters. |
726 intptr_t count = IsCompiledForOsr() ? variable_count() : parameter_count(); | 737 intptr_t count = IsCompiledForOsr() ? variable_count() : parameter_count(); |
727 for (intptr_t i = 0; i < count; ++i) { | 738 for (intptr_t i = 0; i < count; ++i) { |
728 ParameterInstr* param = new ParameterInstr(i, entry); | 739 ParameterInstr* param = new ParameterInstr(i, entry); |
729 param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. | 740 param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
920 // We remove load/store/constant instructions when we find their | 931 // We remove load/store/constant instructions when we find their |
921 // use in 2a. | 932 // use in 2a. |
922 } else { | 933 } else { |
923 it.RemoveCurrentFromGraph(); | 934 it.RemoveCurrentFromGraph(); |
924 } | 935 } |
925 } else { | 936 } else { |
926 // Not a load, store, or constant. | 937 // Not a load, store, or constant. |
927 if (definition->is_used()) { | 938 if (definition->is_used()) { |
928 // Assign fresh SSA temporary and update expression stack. | 939 // Assign fresh SSA temporary and update expression stack. |
929 definition->set_ssa_temp_index(alloc_ssa_temp_index()); | 940 definition->set_ssa_temp_index(alloc_ssa_temp_index()); |
941 if (definition->RequiresTwoSSATempIndexes()) { | |
942 definition->set_ssa_temp_index2(alloc_ssa_temp_index()); | |
943 } | |
930 env->Add(definition); | 944 env->Add(definition); |
931 } | 945 } |
932 } | 946 } |
933 } | 947 } |
934 | 948 |
935 // 2c. Handle pushed argument. | 949 // 2c. Handle pushed argument. |
936 PushArgumentInstr* push = current->AsPushArgument(); | 950 PushArgumentInstr* push = current->AsPushArgument(); |
937 if (push != NULL) { | 951 if (push != NULL) { |
938 env->Add(push); | 952 env->Add(push); |
939 } | 953 } |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1218 } | 1232 } |
1219 | 1233 |
1220 | 1234 |
1221 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, | 1235 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, |
1222 BlockEntryInstr* to) const { | 1236 BlockEntryInstr* to) const { |
1223 return available_at_[to->postorder_number()]->Contains( | 1237 return available_at_[to->postorder_number()]->Contains( |
1224 from->postorder_number()); | 1238 from->postorder_number()); |
1225 } | 1239 } |
1226 | 1240 |
1227 } // namespace dart | 1241 } // namespace dart |
OLD | NEW |