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/growable_array.h" | 10 #include "vm/growable_array.h" |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 instr->env()->set_deopt_id(instr->deopt_id()); | 786 instr->env()->set_deopt_id(instr->deopt_id()); |
787 } | 787 } |
788 } | 788 } |
789 | 789 |
790 | 790 |
791 void FlowGraph::RenameRecursive(BlockEntryInstr* block_entry, | 791 void FlowGraph::RenameRecursive(BlockEntryInstr* block_entry, |
792 GrowableArray<Definition*>* env, | 792 GrowableArray<Definition*>* env, |
793 GrowableArray<PhiInstr*>* live_phis, | 793 GrowableArray<PhiInstr*>* live_phis, |
794 VariableLivenessAnalysis* variable_liveness) { | 794 VariableLivenessAnalysis* variable_liveness) { |
795 // 1. Process phis first. | 795 // 1. Process phis first. |
796 if (block_entry->IsJoinEntry()) { | 796 if (block_entry->IsJoinEntry() || block_entry->IsIndirectEntry()) { |
797 JoinEntryInstr* join = block_entry->AsJoinEntry(); | 797 JoinEntryInstr* join = block_entry->AsJoinEntry(); |
798 if (join->phis() != NULL) { | 798 if (join->phis() != NULL) { |
799 for (intptr_t i = 0; i < join->phis()->length(); ++i) { | 799 for (intptr_t i = 0; i < join->phis()->length(); ++i) { |
800 PhiInstr* phi = (*join->phis())[i]; | 800 PhiInstr* phi = (*join->phis())[i]; |
801 if (phi != NULL) { | 801 if (phi != NULL) { |
802 (*env)[i] = phi; | 802 (*env)[i] = phi; |
803 phi->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. | 803 phi->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. |
804 if (block_entry->InsideTryBlock()) { | 804 if (block_entry->InsideTryBlock()) { |
805 // This is a safe approximation. Inside try{} all locals are | 805 // This is a safe approximation. Inside try{} all locals are |
806 // used at every call implicitly, so we mark all phis as live | 806 // used at every call implicitly, so we mark all phis as live |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 for (intptr_t i = 0; i < block_entry->dominated_blocks().length(); ++i) { | 964 for (intptr_t i = 0; i < block_entry->dominated_blocks().length(); ++i) { |
965 BlockEntryInstr* block = block_entry->dominated_blocks()[i]; | 965 BlockEntryInstr* block = block_entry->dominated_blocks()[i]; |
966 GrowableArray<Definition*> new_env(env->length()); | 966 GrowableArray<Definition*> new_env(env->length()); |
967 new_env.AddArray(*env); | 967 new_env.AddArray(*env); |
968 RenameRecursive(block, &new_env, live_phis, variable_liveness); | 968 RenameRecursive(block, &new_env, live_phis, variable_liveness); |
969 } | 969 } |
970 | 970 |
971 // 4. Process successor block. We have edge-split form, so that only blocks | 971 // 4. Process successor block. We have edge-split form, so that only blocks |
972 // with one successor can have a join block as successor. | 972 // with one successor can have a join block as successor. |
973 if ((block_entry->last_instruction()->SuccessorCount() == 1) && | 973 if ((block_entry->last_instruction()->SuccessorCount() == 1) && |
974 block_entry->last_instruction()->SuccessorAt(0)->IsJoinEntry()) { | 974 (block_entry->last_instruction()->SuccessorAt(0)->IsJoinEntry() || |
| 975 block_entry->last_instruction()->SuccessorAt(0)->IsIndirectEntry())) { |
975 JoinEntryInstr* successor = | 976 JoinEntryInstr* successor = |
976 block_entry->last_instruction()->SuccessorAt(0)->AsJoinEntry(); | 977 block_entry->last_instruction()->SuccessorAt(0)->AsJoinEntry(); |
977 intptr_t pred_index = successor->IndexOfPredecessor(block_entry); | 978 intptr_t pred_index = successor->IndexOfPredecessor(block_entry); |
978 ASSERT(pred_index >= 0); | 979 ASSERT(pred_index >= 0); |
979 if (successor->phis() != NULL) { | 980 if (successor->phis() != NULL) { |
980 for (intptr_t i = 0; i < successor->phis()->length(); ++i) { | 981 for (intptr_t i = 0; i < successor->phis()->length(); ++i) { |
981 PhiInstr* phi = (*successor->phis())[i]; | 982 PhiInstr* phi = (*successor->phis())[i]; |
982 if (phi != NULL) { | 983 if (phi != NULL) { |
983 // Rename input operand. | 984 // Rename input operand. |
984 Value* use = new(isolate()) Value((*env)[i]); | 985 Value* use = new(isolate()) Value((*env)[i]); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 } | 1256 } |
1256 | 1257 |
1257 | 1258 |
1258 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, | 1259 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, |
1259 BlockEntryInstr* to) const { | 1260 BlockEntryInstr* to) const { |
1260 return available_at_[to->postorder_number()]->Contains( | 1261 return available_at_[to->postorder_number()]->Contains( |
1261 from->postorder_number()); | 1262 from->postorder_number()); |
1262 } | 1263 } |
1263 | 1264 |
1264 } // namespace dart | 1265 } // namespace dart |
OLD | NEW |