OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
769 TRACE_GVN_2("Analyzing block B%d%s\n", | 769 TRACE_GVN_2("Analyzing block B%d%s\n", |
770 block->block_id(), | 770 block->block_id(), |
771 block->IsLoopHeader() ? " (loop header)" : ""); | 771 block->IsLoopHeader() ? " (loop header)" : ""); |
772 | 772 |
773 // If this is a loop header kill everything killed by the loop. | 773 // If this is a loop header kill everything killed by the loop. |
774 if (block->IsLoopHeader()) { | 774 if (block->IsLoopHeader()) { |
775 map->Kill(loop_side_effects_[block->block_id()]); | 775 map->Kill(loop_side_effects_[block->block_id()]); |
776 } | 776 } |
777 | 777 |
778 // Go through all instructions of the current block. | 778 // Go through all instructions of the current block. |
779 HInstruction* instr = block->first(); | 779 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { |
Michael Starzinger
2013/07/08 12:44:06
Switching to the HInstructionIterator will break f
Hannes Payer (out of office)
2013/07/08 13:43:48
Done.
| |
780 while (instr != NULL) { | 780 HInstruction* instr = it.Current(); |
781 HInstruction* next = instr->next(); | 781 if (instr->CheckFlag(HValue::kTrackSideEffectDominators)) { |
782 for (int i = 0; i < kNumberOfTrackedSideEffects; i++) { | |
783 HValue* other = dominators->at(i); | |
784 GVNFlag changes_flag = HValue::ChangesFlagFromInt(i); | |
785 GVNFlag depends_on_flag = HValue::DependsOnFlagFromInt(i); | |
786 if (instr->DependsOnFlags().Contains(depends_on_flag) && | |
787 (other != NULL)) { | |
788 TRACE_GVN_5("Side-effect #%d in %d (%s) is dominated by %d (%s)\n", | |
789 i, | |
790 instr->id(), | |
791 instr->Mnemonic(), | |
792 other->id(), | |
793 other->Mnemonic()); | |
794 instr->HandleSideEffectDominator(changes_flag, other); | |
795 } | |
796 } | |
797 } | |
782 GVNFlagSet flags = instr->ChangesFlags(); | 798 GVNFlagSet flags = instr->ChangesFlags(); |
783 if (!flags.IsEmpty()) { | 799 if (instr->IsLinked() && !flags.IsEmpty()) { |
Michael Starzinger
2013/07/08 12:44:06
Instead of doing the IsLinked() checks here, could
Hannes Payer (out of office)
2013/07/08 13:43:48
Done.
| |
784 // Clear all instructions in the map that are affected by side effects. | 800 // Clear all instructions in the map that are affected by side effects. |
785 // Store instruction as the dominating one for tracked side effects. | 801 // Store instruction as the dominating one for tracked side effects. |
786 map->Kill(flags); | 802 map->Kill(flags); |
787 dominators->Store(flags, instr); | 803 dominators->Store(flags, instr); |
788 TRACE_GVN_2("Instruction %d %s\n", instr->id(), | 804 TRACE_GVN_2("Instruction %d %s\n", instr->id(), |
789 *GetGVNFlagsString(flags)); | 805 *GetGVNFlagsString(flags)); |
790 } | 806 } |
791 if (instr->CheckFlag(HValue::kUseGVN)) { | 807 if (instr->IsLinked() && instr->CheckFlag(HValue::kUseGVN)) { |
Michael Starzinger
2013/07/08 12:44:06
Likewise.
Hannes Payer (out of office)
2013/07/08 13:43:48
Done.
| |
792 ASSERT(!instr->HasObservableSideEffects()); | 808 ASSERT(!instr->HasObservableSideEffects()); |
793 HValue* other = map->Lookup(instr); | 809 HValue* other = map->Lookup(instr); |
794 if (other != NULL) { | 810 if (other != NULL) { |
795 ASSERT(instr->Equals(other) && other->Equals(instr)); | 811 ASSERT(instr->Equals(other) && other->Equals(instr)); |
796 TRACE_GVN_4("Replacing value %d (%s) with value %d (%s)\n", | 812 TRACE_GVN_4("Replacing value %d (%s) with value %d (%s)\n", |
797 instr->id(), | 813 instr->id(), |
798 instr->Mnemonic(), | 814 instr->Mnemonic(), |
799 other->id(), | 815 other->id(), |
800 other->Mnemonic()); | 816 other->Mnemonic()); |
801 if (instr->HasSideEffects()) removed_side_effects_ = true; | 817 if (instr->HasSideEffects()) removed_side_effects_ = true; |
802 instr->DeleteAndReplaceWith(other); | 818 instr->DeleteAndReplaceWith(other); |
803 } else { | 819 } else { |
804 map->Add(instr, zone()); | 820 map->Add(instr, zone()); |
805 } | 821 } |
806 } | 822 } |
807 if (instr->IsLinked() && | |
808 instr->CheckFlag(HValue::kTrackSideEffectDominators)) { | |
809 for (int i = 0; i < kNumberOfTrackedSideEffects; i++) { | |
810 HValue* other = dominators->at(i); | |
811 GVNFlag changes_flag = HValue::ChangesFlagFromInt(i); | |
812 GVNFlag depends_on_flag = HValue::DependsOnFlagFromInt(i); | |
813 if (instr->DependsOnFlags().Contains(depends_on_flag) && | |
814 (other != NULL)) { | |
815 TRACE_GVN_5("Side-effect #%d in %d (%s) is dominated by %d (%s)\n", | |
816 i, | |
817 instr->id(), | |
818 instr->Mnemonic(), | |
819 other->id(), | |
820 other->Mnemonic()); | |
821 instr->SetSideEffectDominator(changes_flag, other); | |
822 } | |
823 } | |
824 } | |
825 instr = next; | |
826 } | 823 } |
827 | 824 |
828 HBasicBlock* dominator_block; | 825 HBasicBlock* dominator_block; |
829 GvnBasicBlockState* next = | 826 GvnBasicBlockState* next = |
830 current->next_in_dominator_tree_traversal(zone(), | 827 current->next_in_dominator_tree_traversal(zone(), |
831 &dominator_block); | 828 &dominator_block); |
832 | 829 |
833 if (next != NULL) { | 830 if (next != NULL) { |
834 HBasicBlock* dominated = next->block(); | 831 HBasicBlock* dominated = next->block(); |
835 HValueMap* successor_map = next->map(); | 832 HValueMap* successor_map = next->map(); |
(...skipping 12 matching lines...) Expand all Loading... | |
848 dominated); | 845 dominated); |
849 successor_map->Kill(side_effects_on_all_paths); | 846 successor_map->Kill(side_effects_on_all_paths); |
850 successor_dominators->Kill(side_effects_on_all_paths); | 847 successor_dominators->Kill(side_effects_on_all_paths); |
851 } | 848 } |
852 } | 849 } |
853 current = next; | 850 current = next; |
854 } | 851 } |
855 } | 852 } |
856 | 853 |
857 } } // namespace v8::internal | 854 } } // namespace v8::internal |
OLD | NEW |