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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 : HPhase("H_Global value numbering", graph), | 367 : HPhase("H_Global value numbering", graph), |
368 removed_side_effects_(false), | 368 removed_side_effects_(false), |
369 block_side_effects_(graph->blocks()->length(), zone()), | 369 block_side_effects_(graph->blocks()->length(), zone()), |
370 loop_side_effects_(graph->blocks()->length(), zone()), | 370 loop_side_effects_(graph->blocks()->length(), zone()), |
371 visited_on_paths_(graph->blocks()->length(), zone()) { | 371 visited_on_paths_(graph->blocks()->length(), zone()) { |
372 ASSERT(!AllowHandleAllocation::IsAllowed()); | 372 ASSERT(!AllowHandleAllocation::IsAllowed()); |
373 block_side_effects_.AddBlock(GVNFlagSet(), graph->blocks()->length(), | 373 block_side_effects_.AddBlock(GVNFlagSet(), graph->blocks()->length(), |
374 zone()); | 374 zone()); |
375 loop_side_effects_.AddBlock(GVNFlagSet(), graph->blocks()->length(), | 375 loop_side_effects_.AddBlock(GVNFlagSet(), graph->blocks()->length(), |
376 zone()); | 376 zone()); |
377 } | 377 } |
| 378 |
| 379 |
| 380 void HGlobalValueNumberingPhase::Reset() { |
| 381 block_side_effects_.Clear(); |
| 382 loop_side_effects_.Clear(); |
| 383 visited_on_paths_.Clear(); |
| 384 block_side_effects_.AddBlock(GVNFlagSet(), graph()->blocks()->length(), |
| 385 zone()); |
| 386 loop_side_effects_.AddBlock(GVNFlagSet(), graph()->blocks()->length(), |
| 387 zone()); |
| 388 } |
| 389 |
378 | 390 |
379 void HGlobalValueNumberingPhase::Analyze() { | 391 void HGlobalValueNumberingPhase::Analyze() { |
380 removed_side_effects_ = false; | 392 removed_side_effects_ = false; |
381 ComputeBlockSideEffects(); | 393 ComputeBlockSideEffects(); |
382 if (FLAG_loop_invariant_code_motion) { | 394 if (FLAG_loop_invariant_code_motion) { |
383 LoopInvariantCodeMotion(); | 395 LoopInvariantCodeMotion(); |
384 } | 396 } |
385 AnalyzeGraph(); | 397 AnalyzeGraph(); |
386 } | 398 } |
387 | 399 |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 GVNFlag changes_flag = HValue::ChangesFlagFromInt(i); | 796 GVNFlag changes_flag = HValue::ChangesFlagFromInt(i); |
785 GVNFlag depends_on_flag = HValue::DependsOnFlagFromInt(i); | 797 GVNFlag depends_on_flag = HValue::DependsOnFlagFromInt(i); |
786 if (instr->DependsOnFlags().Contains(depends_on_flag) && | 798 if (instr->DependsOnFlags().Contains(depends_on_flag) && |
787 (other != NULL)) { | 799 (other != NULL)) { |
788 TRACE_GVN_5("Side-effect #%d in %d (%s) is dominated by %d (%s)\n", | 800 TRACE_GVN_5("Side-effect #%d in %d (%s) is dominated by %d (%s)\n", |
789 i, | 801 i, |
790 instr->id(), | 802 instr->id(), |
791 instr->Mnemonic(), | 803 instr->Mnemonic(), |
792 other->id(), | 804 other->id(), |
793 other->Mnemonic()); | 805 other->Mnemonic()); |
794 instr->HandleSideEffectDominator(changes_flag, other); | 806 if (instr->HandleSideEffectDominator(changes_flag, other)) { |
| 807 removed_side_effects_ = true; |
| 808 } |
795 } | 809 } |
796 } | 810 } |
797 } | 811 } |
798 // Instruction was unlinked during graph traversal. | 812 // Instruction was unlinked during graph traversal. |
799 if (!instr->IsLinked()) continue; | 813 if (!instr->IsLinked()) continue; |
800 | 814 |
801 GVNFlagSet flags = instr->ChangesFlags(); | 815 GVNFlagSet flags = instr->ChangesFlags(); |
802 if (!flags.IsEmpty()) { | 816 if (!flags.IsEmpty()) { |
803 // Clear all instructions in the map that are affected by side effects. | 817 // Clear all instructions in the map that are affected by side effects. |
804 // Store instruction as the dominating one for tracked side effects. | 818 // Store instruction as the dominating one for tracked side effects. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 dominated); | 862 dominated); |
849 successor_map->Kill(side_effects_on_all_paths); | 863 successor_map->Kill(side_effects_on_all_paths); |
850 successor_dominators->Kill(side_effects_on_all_paths); | 864 successor_dominators->Kill(side_effects_on_all_paths); |
851 } | 865 } |
852 } | 866 } |
853 current = next; | 867 current = next; |
854 } | 868 } |
855 } | 869 } |
856 | 870 |
857 } } // namespace v8::internal | 871 } } // namespace v8::internal |
OLD | NEW |