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 2964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2975 | 2975 |
2976 if (FLAG_use_gvn) Run<HGlobalValueNumberingPhase>(); | 2976 if (FLAG_use_gvn) Run<HGlobalValueNumberingPhase>(); |
2977 | 2977 |
2978 if (FLAG_use_range) Run<HRangeAnalysisPhase>(); | 2978 if (FLAG_use_range) Run<HRangeAnalysisPhase>(); |
2979 | 2979 |
2980 Run<HComputeMinusZeroChecksPhase>(); | 2980 Run<HComputeMinusZeroChecksPhase>(); |
2981 | 2981 |
2982 // Eliminate redundant stack checks on backwards branches. | 2982 // Eliminate redundant stack checks on backwards branches. |
2983 Run<HStackCheckEliminationPhase>(); | 2983 Run<HStackCheckEliminationPhase>(); |
2984 | 2984 |
2985 if (FLAG_idefs) SetupInformativeDefinitions(); | 2985 if (FLAG_array_bounds_checks_elimination) { |
2986 if (FLAG_array_bounds_checks_elimination && !FLAG_idefs) { | |
2987 Run<HBoundsCheckEliminationPhase>(); | 2986 Run<HBoundsCheckEliminationPhase>(); |
2988 } | 2987 } |
2989 if (FLAG_array_bounds_checks_hoisting && !FLAG_idefs) { | 2988 if (FLAG_array_bounds_checks_hoisting) { |
2990 Run<HBoundsCheckHoistingPhase>(); | 2989 Run<HBoundsCheckHoistingPhase>(); |
2991 } | 2990 } |
2992 if (FLAG_array_index_dehoisting) Run<HDehoistIndexComputationsPhase>(); | 2991 if (FLAG_array_index_dehoisting) Run<HDehoistIndexComputationsPhase>(); |
2993 if (FLAG_dead_code_elimination) Run<HDeadCodeEliminationPhase>(); | 2992 if (FLAG_dead_code_elimination) Run<HDeadCodeEliminationPhase>(); |
2994 | 2993 |
2995 RestoreActualValues(); | 2994 RestoreActualValues(); |
2996 | 2995 |
2997 return true; | 2996 return true; |
2998 } | 2997 } |
2999 | 2998 |
3000 | 2999 |
3001 void HGraph::SetupInformativeDefinitionsInBlock(HBasicBlock* block) { | |
3002 for (int phi_index = 0; phi_index < block->phis()->length(); phi_index++) { | |
3003 HPhi* phi = block->phis()->at(phi_index); | |
3004 phi->AddInformativeDefinitions(); | |
3005 phi->SetFlag(HValue::kIDefsProcessingDone); | |
3006 // We do not support phis that "redefine just one operand". | |
3007 ASSERT(!phi->IsInformativeDefinition()); | |
3008 } | |
3009 | |
3010 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { | |
3011 HInstruction* i = it.Current(); | |
3012 i->AddInformativeDefinitions(); | |
3013 i->SetFlag(HValue::kIDefsProcessingDone); | |
3014 i->UpdateRedefinedUsesWhileSettingUpInformativeDefinitions(); | |
3015 } | |
3016 } | |
3017 | |
3018 | |
3019 // This method is recursive, so if its stack frame is large it could | |
3020 // cause a stack overflow. | |
3021 // To keep the individual stack frames small we do the actual work inside | |
3022 // SetupInformativeDefinitionsInBlock(); | |
3023 void HGraph::SetupInformativeDefinitionsRecursively(HBasicBlock* block) { | |
3024 SetupInformativeDefinitionsInBlock(block); | |
3025 for (int i = 0; i < block->dominated_blocks()->length(); ++i) { | |
3026 SetupInformativeDefinitionsRecursively(block->dominated_blocks()->at(i)); | |
3027 } | |
3028 | |
3029 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { | |
3030 HInstruction* i = it.Current(); | |
3031 if (i->IsBoundsCheck()) { | |
3032 HBoundsCheck* check = HBoundsCheck::cast(i); | |
3033 check->ApplyIndexChange(); | |
3034 } | |
3035 } | |
3036 } | |
3037 | |
3038 | |
3039 void HGraph::SetupInformativeDefinitions() { | |
3040 HPhase phase("H_Setup informative definitions", this); | |
3041 SetupInformativeDefinitionsRecursively(entry_block()); | |
3042 } | |
3043 | |
3044 | |
3045 void HGraph::RestoreActualValues() { | 3000 void HGraph::RestoreActualValues() { |
3046 HPhase phase("H_Restore actual values", this); | 3001 HPhase phase("H_Restore actual values", this); |
3047 | 3002 |
3048 for (int block_index = 0; block_index < blocks()->length(); block_index++) { | 3003 for (int block_index = 0; block_index < blocks()->length(); block_index++) { |
3049 HBasicBlock* block = blocks()->at(block_index); | 3004 HBasicBlock* block = blocks()->at(block_index); |
3050 | 3005 |
3051 #ifdef DEBUG | 3006 #ifdef DEBUG |
3052 for (int i = 0; i < block->phis()->length(); i++) { | 3007 for (int i = 0; i < block->phis()->length(); i++) { |
3053 HPhi* phi = block->phis()->at(i); | 3008 HPhi* phi = block->phis()->at(i); |
3054 ASSERT(phi->ActualValue() == phi); | 3009 ASSERT(phi->ActualValue() == phi); |
(...skipping 6724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9779 if (ShouldProduceTraceOutput()) { | 9734 if (ShouldProduceTraceOutput()) { |
9780 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 9735 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
9781 } | 9736 } |
9782 | 9737 |
9783 #ifdef DEBUG | 9738 #ifdef DEBUG |
9784 graph_->Verify(false); // No full verify. | 9739 graph_->Verify(false); // No full verify. |
9785 #endif | 9740 #endif |
9786 } | 9741 } |
9787 | 9742 |
9788 } } // namespace v8::internal | 9743 } } // namespace v8::internal |
OLD | NEW |