| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2964 if (current->representation().IsNone() && | 2964 if (current->representation().IsNone() && |
| 2965 current->CheckFlag(HInstruction::kFlexibleRepresentation)) { | 2965 current->CheckFlag(HInstruction::kFlexibleRepresentation)) { |
| 2966 current->ChangeRepresentation(Representation::Tagged()); | 2966 current->ChangeRepresentation(Representation::Tagged()); |
| 2967 } | 2967 } |
| 2968 } | 2968 } |
| 2969 } | 2969 } |
| 2970 } | 2970 } |
| 2971 | 2971 |
| 2972 | 2972 |
| 2973 void HGraph::MergeRemovableSimulates() { | 2973 void HGraph::MergeRemovableSimulates() { |
| 2974 ZoneList<HSimulate*> mergelist(2, zone()); |
| 2974 for (int i = 0; i < blocks()->length(); ++i) { | 2975 for (int i = 0; i < blocks()->length(); ++i) { |
| 2975 HBasicBlock* block = blocks()->at(i); | 2976 HBasicBlock* block = blocks()->at(i); |
| 2976 // Always reset the folding candidate at the start of a block. | 2977 // Make sure the merge list is empty at the start of a block. |
| 2977 HSimulate* folding_candidate = NULL; | 2978 ASSERT(mergelist.is_empty()); |
| 2978 // Nasty heuristic: Never remove the first simulate in a block. This | 2979 // Nasty heuristic: Never remove the first simulate in a block. This |
| 2979 // just so happens to have a beneficial effect on register allocation. | 2980 // just so happens to have a beneficial effect on register allocation. |
| 2980 bool first = true; | 2981 bool first = true; |
| 2981 for (HInstruction* current = block->first(); | 2982 for (HInstruction* current = block->first(); |
| 2982 current != NULL; current = current->next()) { | 2983 current != NULL; current = current->next()) { |
| 2983 if (current->IsLeaveInlined()) { | 2984 if (current->IsLeaveInlined()) { |
| 2984 // Never fold simulates from inlined environments into simulates | 2985 // Never fold simulates from inlined environments into simulates |
| 2985 // in the outer environment. | 2986 // in the outer environment. |
| 2986 // (Before each HEnterInlined, there is a non-foldable HSimulate | 2987 // (Before each HEnterInlined, there is a non-foldable HSimulate |
| 2987 // anyway, so we get the barrier in the other direction for free.) | 2988 // anyway, so we get the barrier in the other direction for free.) |
| 2988 if (folding_candidate != NULL) { | 2989 // Simply remove all accumulated simulates without merging. This |
| 2989 folding_candidate->DeleteAndReplaceWith(NULL); | 2990 // is safe because simulates after instructions with side effects |
| 2991 // are never added to the merge list. |
| 2992 while (!mergelist.is_empty()) { |
| 2993 mergelist.RemoveLast()->DeleteAndReplaceWith(NULL); |
| 2990 } | 2994 } |
| 2991 folding_candidate = NULL; | |
| 2992 continue; | 2995 continue; |
| 2993 } | 2996 } |
| 2994 // If we have an HSimulate and a candidate, perform the folding. | 2997 // Skip the non-simulates and the first simulate. |
| 2995 if (!current->IsSimulate()) continue; | 2998 if (!current->IsSimulate()) continue; |
| 2996 if (first) { | 2999 if (first) { |
| 2997 first = false; | 3000 first = false; |
| 2998 continue; | 3001 continue; |
| 2999 } | 3002 } |
| 3000 HSimulate* current_simulate = HSimulate::cast(current); | 3003 HSimulate* current_simulate = HSimulate::cast(current); |
| 3001 if (folding_candidate != NULL) { | 3004 if ((current_simulate->previous()->HasObservableSideEffects() && |
| 3002 folding_candidate->MergeInto(current_simulate); | 3005 !current_simulate->next()->IsSimulate()) || |
| 3003 folding_candidate->DeleteAndReplaceWith(NULL); | 3006 !current_simulate->is_candidate_for_removal()) { |
| 3004 folding_candidate = NULL; | 3007 // This simulate is not suitable for folding. |
| 3008 // Fold the ones accumulated so far. |
| 3009 current_simulate->MergeWith(&mergelist); |
| 3010 continue; |
| 3011 } else { |
| 3012 // Accumulate this simulate for folding later on. |
| 3013 mergelist.Add(current_simulate, zone()); |
| 3005 } | 3014 } |
| 3006 // Check if the current simulate is a candidate for folding. | 3015 } |
| 3007 if (current_simulate->previous()->HasObservableSideEffects() && | 3016 |
| 3008 !current_simulate->next()->IsSimulate()) { | 3017 if (!mergelist.is_empty()) { |
| 3009 continue; | 3018 // Merge the accumulated simulates at the end of the block. |
| 3010 } | 3019 HSimulate* last = mergelist.RemoveLast(); |
| 3011 if (!current_simulate->is_candidate_for_removal()) { | 3020 last->MergeWith(&mergelist); |
| 3012 continue; | |
| 3013 } | |
| 3014 folding_candidate = current_simulate; | |
| 3015 } | 3021 } |
| 3016 } | 3022 } |
| 3017 } | 3023 } |
| 3018 | 3024 |
| 3019 | 3025 |
| 3020 void HGraph::InitializeInferredTypes() { | 3026 void HGraph::InitializeInferredTypes() { |
| 3021 HPhase phase("H_Inferring types", this); | 3027 HPhase phase("H_Inferring types", this); |
| 3022 InitializeInferredTypes(0, this->blocks_.length() - 1); | 3028 InitializeInferredTypes(0, this->blocks_.length() - 1); |
| 3023 } | 3029 } |
| 3024 | 3030 |
| (...skipping 7769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10794 } | 10800 } |
| 10795 } | 10801 } |
| 10796 | 10802 |
| 10797 #ifdef DEBUG | 10803 #ifdef DEBUG |
| 10798 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 10804 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 10799 if (allocator_ != NULL) allocator_->Verify(); | 10805 if (allocator_ != NULL) allocator_->Verify(); |
| 10800 #endif | 10806 #endif |
| 10801 } | 10807 } |
| 10802 | 10808 |
| 10803 } } // namespace v8::internal | 10809 } } // namespace v8::internal |
| OLD | NEW |