Chromium Code Reviews| 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()) { |
| 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 } | |
| 798 // Instruction was unlinked during graph traversal. | |
| 799 if (!instr->IsLinked()) { | |
| 800 continue; | |
|
Michael Starzinger
2013/07/08 14:02:43
nit: The whole condition should fit into one line.
Hannes Payer (out of office)
2013/07/09 08:26:15
Done.
| |
| 801 } | |
| 782 GVNFlagSet flags = instr->ChangesFlags(); | 802 GVNFlagSet flags = instr->ChangesFlags(); |
| 783 if (!flags.IsEmpty()) { | 803 if (!flags.IsEmpty()) { |
| 784 // Clear all instructions in the map that are affected by side effects. | 804 // Clear all instructions in the map that are affected by side effects. |
| 785 // Store instruction as the dominating one for tracked side effects. | 805 // Store instruction as the dominating one for tracked side effects. |
| 786 map->Kill(flags); | 806 map->Kill(flags); |
| 787 dominators->Store(flags, instr); | 807 dominators->Store(flags, instr); |
| 788 TRACE_GVN_2("Instruction %d %s\n", instr->id(), | 808 TRACE_GVN_2("Instruction %d %s\n", instr->id(), |
| 789 *GetGVNFlagsString(flags)); | 809 *GetGVNFlagsString(flags)); |
| 790 } | 810 } |
| 791 if (instr->CheckFlag(HValue::kUseGVN)) { | 811 if (instr->CheckFlag(HValue::kUseGVN)) { |
| 792 ASSERT(!instr->HasObservableSideEffects()); | 812 ASSERT(!instr->HasObservableSideEffects()); |
| 793 HValue* other = map->Lookup(instr); | 813 HValue* other = map->Lookup(instr); |
| 794 if (other != NULL) { | 814 if (other != NULL) { |
| 795 ASSERT(instr->Equals(other) && other->Equals(instr)); | 815 ASSERT(instr->Equals(other) && other->Equals(instr)); |
| 796 TRACE_GVN_4("Replacing value %d (%s) with value %d (%s)\n", | 816 TRACE_GVN_4("Replacing value %d (%s) with value %d (%s)\n", |
| 797 instr->id(), | 817 instr->id(), |
| 798 instr->Mnemonic(), | 818 instr->Mnemonic(), |
| 799 other->id(), | 819 other->id(), |
| 800 other->Mnemonic()); | 820 other->Mnemonic()); |
| 801 if (instr->HasSideEffects()) removed_side_effects_ = true; | 821 if (instr->HasSideEffects()) removed_side_effects_ = true; |
| 802 instr->DeleteAndReplaceWith(other); | 822 instr->DeleteAndReplaceWith(other); |
| 803 } else { | 823 } else { |
| 804 map->Add(instr, zone()); | 824 map->Add(instr, zone()); |
| 805 } | 825 } |
| 806 } | 826 } |
| 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 } | 827 } |
| 827 | 828 |
| 828 HBasicBlock* dominator_block; | 829 HBasicBlock* dominator_block; |
| 829 GvnBasicBlockState* next = | 830 GvnBasicBlockState* next = |
| 830 current->next_in_dominator_tree_traversal(zone(), | 831 current->next_in_dominator_tree_traversal(zone(), |
| 831 &dominator_block); | 832 &dominator_block); |
| 832 | 833 |
| 833 if (next != NULL) { | 834 if (next != NULL) { |
| 834 HBasicBlock* dominated = next->block(); | 835 HBasicBlock* dominated = next->block(); |
| 835 HValueMap* successor_map = next->map(); | 836 HValueMap* successor_map = next->map(); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 848 dominated); | 849 dominated); |
| 849 successor_map->Kill(side_effects_on_all_paths); | 850 successor_map->Kill(side_effects_on_all_paths); |
| 850 successor_dominators->Kill(side_effects_on_all_paths); | 851 successor_dominators->Kill(side_effects_on_all_paths); |
| 851 } | 852 } |
| 852 } | 853 } |
| 853 current = next; | 854 current = next; |
| 854 } | 855 } |
| 855 } | 856 } |
| 856 | 857 |
| 857 } } // namespace v8::internal | 858 } } // namespace v8::internal |
| OLD | NEW |