| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cpu.h" | 8 #include "vm/cpu.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flow_graph_allocator.h" | 10 #include "vm/flow_graph_allocator.h" |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 } | 764 } |
| 765 | 765 |
| 766 | 766 |
| 767 void BranchInstr::InheritDeoptTarget(Isolate* isolate, Instruction* other) { | 767 void BranchInstr::InheritDeoptTarget(Isolate* isolate, Instruction* other) { |
| 768 ASSERT(env() == NULL); | 768 ASSERT(env() == NULL); |
| 769 Instruction::InheritDeoptTarget(isolate, other); | 769 Instruction::InheritDeoptTarget(isolate, other); |
| 770 comparison()->SetDeoptId(GetDeoptId()); | 770 comparison()->SetDeoptId(GetDeoptId()); |
| 771 } | 771 } |
| 772 | 772 |
| 773 | 773 |
| 774 bool Instruction::IsDominatedBy(Instruction* dom) { |
| 775 BlockEntryInstr* block = GetBlock(); |
| 776 BlockEntryInstr* dom_block = dom->GetBlock(); |
| 777 |
| 778 if (dom->IsPhi()) { |
| 779 dom = dom_block; |
| 780 } |
| 781 |
| 782 if (block == dom_block) { |
| 783 if ((block == dom) || (this == block->last_instruction())) { |
| 784 return true; |
| 785 } |
| 786 |
| 787 if (IsPhi()) { |
| 788 return false; |
| 789 } |
| 790 |
| 791 for (Instruction* curr = dom->next(); curr != NULL; curr = curr->next()) { |
| 792 if (curr == this) return true; |
| 793 } |
| 794 |
| 795 return false; |
| 796 } |
| 797 |
| 798 return dom_block->Dominates(block); |
| 799 } |
| 800 |
| 801 |
| 774 void Definition::ReplaceWith(Definition* other, | 802 void Definition::ReplaceWith(Definition* other, |
| 775 ForwardInstructionIterator* iterator) { | 803 ForwardInstructionIterator* iterator) { |
| 776 // Record other's input uses. | 804 // Record other's input uses. |
| 777 for (intptr_t i = other->InputCount() - 1; i >= 0; --i) { | 805 for (intptr_t i = other->InputCount() - 1; i >= 0; --i) { |
| 778 Value* input = other->InputAt(i); | 806 Value* input = other->InputAt(i); |
| 779 input->definition()->AddInputUse(input); | 807 input->definition()->AddInputUse(input); |
| 780 } | 808 } |
| 781 // Take other's environment from this definition. | 809 // Take other's environment from this definition. |
| 782 ASSERT(other->env() == NULL); | 810 ASSERT(other->env() == NULL); |
| 783 other->SetEnvironment(env()); | 811 other->SetEnvironment(env()); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 // block while computing the dominator tree. | 984 // block while computing the dominator tree. |
| 957 ASSERT(other != NULL); | 985 ASSERT(other != NULL); |
| 958 BlockEntryInstr* current = other; | 986 BlockEntryInstr* current = other; |
| 959 while (current != NULL && current != this) { | 987 while (current != NULL && current != this) { |
| 960 current = current->dominator(); | 988 current = current->dominator(); |
| 961 } | 989 } |
| 962 return current == this; | 990 return current == this; |
| 963 } | 991 } |
| 964 | 992 |
| 965 | 993 |
| 994 BlockEntryInstr* BlockEntryInstr::ImmediateDominator() const { |
| 995 Instruction* last = dominator()->last_instruction(); |
| 996 if ((last->SuccessorCount() == 1) && (last->SuccessorAt(0) == this)) { |
| 997 return dominator(); |
| 998 } |
| 999 return NULL; |
| 1000 } |
| 1001 |
| 1002 |
| 966 // Helper to mutate the graph during inlining. This block should be | 1003 // Helper to mutate the graph during inlining. This block should be |
| 967 // replaced with new_block as a predecessor of all of this block's | 1004 // replaced with new_block as a predecessor of all of this block's |
| 968 // successors. For each successor, the predecessors will be reordered | 1005 // successors. For each successor, the predecessors will be reordered |
| 969 // to preserve block-order sorting of the predecessors as well as the | 1006 // to preserve block-order sorting of the predecessors as well as the |
| 970 // phis if the successor is a join. | 1007 // phis if the successor is a join. |
| 971 void BlockEntryInstr::ReplaceAsPredecessorWith(BlockEntryInstr* new_block) { | 1008 void BlockEntryInstr::ReplaceAsPredecessorWith(BlockEntryInstr* new_block) { |
| 972 // Set the last instruction of the new block to that of the old block. | 1009 // Set the last instruction of the new block to that of the old block. |
| 973 Instruction* last = last_instruction(); | 1010 Instruction* last = last_instruction(); |
| 974 new_block->set_last_instruction(last); | 1011 new_block->set_last_instruction(last); |
| 975 // For each successor, update the predecessors. | 1012 // For each successor, update the predecessors. |
| (...skipping 2359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3335 case Token::kTRUNCDIV: return 0; | 3372 case Token::kTRUNCDIV: return 0; |
| 3336 case Token::kMOD: return 1; | 3373 case Token::kMOD: return 1; |
| 3337 default: UNIMPLEMENTED(); return -1; | 3374 default: UNIMPLEMENTED(); return -1; |
| 3338 } | 3375 } |
| 3339 } | 3376 } |
| 3340 | 3377 |
| 3341 | 3378 |
| 3342 #undef __ | 3379 #undef __ |
| 3343 | 3380 |
| 3344 } // namespace dart | 3381 } // namespace dart |
| OLD | NEW |