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 26 matching lines...) Expand all Loading... |
37 #include "hydrogen-dce.h" | 37 #include "hydrogen-dce.h" |
38 #include "hydrogen-environment-liveness.h" | 38 #include "hydrogen-environment-liveness.h" |
39 #include "hydrogen-escape-analysis.h" | 39 #include "hydrogen-escape-analysis.h" |
40 #include "hydrogen-infer-representation.h" | 40 #include "hydrogen-infer-representation.h" |
41 #include "hydrogen-infer-types.h" | 41 #include "hydrogen-infer-types.h" |
42 #include "hydrogen-gvn.h" | 42 #include "hydrogen-gvn.h" |
43 #include "hydrogen-minus-zero.h" | 43 #include "hydrogen-minus-zero.h" |
44 #include "hydrogen-osr.h" | 44 #include "hydrogen-osr.h" |
45 #include "hydrogen-range-analysis.h" | 45 #include "hydrogen-range-analysis.h" |
46 #include "hydrogen-redundant-phi.h" | 46 #include "hydrogen-redundant-phi.h" |
| 47 #include "hydrogen-removable-simulates.h" |
47 #include "hydrogen-representation-changes.h" | 48 #include "hydrogen-representation-changes.h" |
48 #include "hydrogen-sce.h" | 49 #include "hydrogen-sce.h" |
49 #include "hydrogen-uint32-analysis.h" | 50 #include "hydrogen-uint32-analysis.h" |
50 #include "lithium-allocator.h" | 51 #include "lithium-allocator.h" |
51 #include "parser.h" | 52 #include "parser.h" |
52 #include "scopeinfo.h" | 53 #include "scopeinfo.h" |
53 #include "scopes.h" | 54 #include "scopes.h" |
54 #include "stub-cache.h" | 55 #include "stub-cache.h" |
55 #include "typing.h" | 56 #include "typing.h" |
56 | 57 |
(...skipping 2508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2565 phi_list_ = new(zone()) ZoneList<HPhi*>(block_count, zone()); | 2566 phi_list_ = new(zone()) ZoneList<HPhi*>(block_count, zone()); |
2566 for (int i = 0; i < block_count; ++i) { | 2567 for (int i = 0; i < block_count; ++i) { |
2567 for (int j = 0; j < blocks_[i]->phis()->length(); ++j) { | 2568 for (int j = 0; j < blocks_[i]->phis()->length(); ++j) { |
2568 HPhi* phi = blocks_[i]->phis()->at(j); | 2569 HPhi* phi = blocks_[i]->phis()->at(j); |
2569 phi_list_->Add(phi, zone()); | 2570 phi_list_->Add(phi, zone()); |
2570 } | 2571 } |
2571 } | 2572 } |
2572 } | 2573 } |
2573 | 2574 |
2574 | 2575 |
2575 void HGraph::MergeRemovableSimulates() { | |
2576 HPhase phase("H_Merge removable simulates", this); | |
2577 ZoneList<HSimulate*> mergelist(2, zone()); | |
2578 for (int i = 0; i < blocks()->length(); ++i) { | |
2579 HBasicBlock* block = blocks()->at(i); | |
2580 // Make sure the merge list is empty at the start of a block. | |
2581 ASSERT(mergelist.is_empty()); | |
2582 // Nasty heuristic: Never remove the first simulate in a block. This | |
2583 // just so happens to have a beneficial effect on register allocation. | |
2584 bool first = true; | |
2585 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { | |
2586 HInstruction* current = it.Current(); | |
2587 if (current->IsLeaveInlined()) { | |
2588 // Never fold simulates from inlined environments into simulates | |
2589 // in the outer environment. | |
2590 // (Before each HEnterInlined, there is a non-foldable HSimulate | |
2591 // anyway, so we get the barrier in the other direction for free.) | |
2592 // Simply remove all accumulated simulates without merging. This | |
2593 // is safe because simulates after instructions with side effects | |
2594 // are never added to the merge list. | |
2595 while (!mergelist.is_empty()) { | |
2596 mergelist.RemoveLast()->DeleteAndReplaceWith(NULL); | |
2597 } | |
2598 continue; | |
2599 } | |
2600 if (current->IsReturn()) { | |
2601 // Drop mergeable simulates in the list. This is safe because | |
2602 // simulates after instructions with side effects are never added | |
2603 // to the merge list. | |
2604 while (!mergelist.is_empty()) { | |
2605 mergelist.RemoveLast()->DeleteAndReplaceWith(NULL); | |
2606 } | |
2607 continue; | |
2608 } | |
2609 // Skip the non-simulates and the first simulate. | |
2610 if (!current->IsSimulate()) continue; | |
2611 if (first) { | |
2612 first = false; | |
2613 continue; | |
2614 } | |
2615 HSimulate* current_simulate = HSimulate::cast(current); | |
2616 if ((current_simulate->previous()->HasObservableSideEffects() && | |
2617 !current_simulate->next()->IsSimulate()) || | |
2618 !current_simulate->is_candidate_for_removal()) { | |
2619 // This simulate is not suitable for folding. | |
2620 // Fold the ones accumulated so far. | |
2621 current_simulate->MergeWith(&mergelist); | |
2622 continue; | |
2623 } else { | |
2624 // Accumulate this simulate for folding later on. | |
2625 mergelist.Add(current_simulate, zone()); | |
2626 } | |
2627 } | |
2628 | |
2629 if (!mergelist.is_empty()) { | |
2630 // Merge the accumulated simulates at the end of the block. | |
2631 HSimulate* last = mergelist.RemoveLast(); | |
2632 last->MergeWith(&mergelist); | |
2633 } | |
2634 } | |
2635 } | |
2636 | |
2637 | |
2638 void HGraph::RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi* phi) { | 2576 void HGraph::RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi* phi) { |
2639 if (!phi->CheckFlag(HValue::kAllowUndefinedAsNaN)) return; | 2577 if (!phi->CheckFlag(HValue::kAllowUndefinedAsNaN)) return; |
2640 phi->ClearFlag(HValue::kAllowUndefinedAsNaN); | 2578 phi->ClearFlag(HValue::kAllowUndefinedAsNaN); |
2641 for (int i = 0; i < phi->OperandCount(); ++i) { | 2579 for (int i = 0; i < phi->OperandCount(); ++i) { |
2642 HValue* input = phi->OperandAt(i); | 2580 HValue* input = phi->OperandAt(i); |
2643 if (input->IsPhi()) { | 2581 if (input->IsPhi()) { |
2644 RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi::cast(input)); | 2582 RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi::cast(input)); |
2645 } | 2583 } |
2646 } | 2584 } |
2647 } | 2585 } |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3130 if (FLAG_dead_code_elimination) Run<HDeadCodeEliminationPhase>(); | 3068 if (FLAG_dead_code_elimination) Run<HDeadCodeEliminationPhase>(); |
3131 CollectPhis(); | 3069 CollectPhis(); |
3132 | 3070 |
3133 if (has_osr()) osr()->FinishOsrValues(); | 3071 if (has_osr()) osr()->FinishOsrValues(); |
3134 | 3072 |
3135 Run<HInferRepresentationPhase>(); | 3073 Run<HInferRepresentationPhase>(); |
3136 | 3074 |
3137 // Remove HSimulate instructions that have turned out not to be needed | 3075 // Remove HSimulate instructions that have turned out not to be needed |
3138 // after all by folding them into the following HSimulate. | 3076 // after all by folding them into the following HSimulate. |
3139 // This must happen after inferring representations. | 3077 // This must happen after inferring representations. |
3140 MergeRemovableSimulates(); | 3078 Run<HMergeRemovableSimulatesPhase>(); |
3141 | 3079 |
3142 MarkDeoptimizeOnUndefined(); | 3080 MarkDeoptimizeOnUndefined(); |
3143 Run<HRepresentationChangesPhase>(); | 3081 Run<HRepresentationChangesPhase>(); |
3144 | 3082 |
3145 Run<HInferTypesPhase>(); | 3083 Run<HInferTypesPhase>(); |
3146 | 3084 |
3147 // Must be performed before canonicalization to ensure that Canonicalize | 3085 // Must be performed before canonicalization to ensure that Canonicalize |
3148 // will not remove semantically meaningful ToInt32 operations e.g. BIT_OR with | 3086 // will not remove semantically meaningful ToInt32 operations e.g. BIT_OR with |
3149 // zero. | 3087 // zero. |
3150 if (FLAG_opt_safe_uint32_operations) Run<HUint32AnalysisPhase>(); | 3088 if (FLAG_opt_safe_uint32_operations) Run<HUint32AnalysisPhase>(); |
(...skipping 7025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10176 if (ShouldProduceTraceOutput()) { | 10114 if (ShouldProduceTraceOutput()) { |
10177 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 10115 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
10178 } | 10116 } |
10179 | 10117 |
10180 #ifdef DEBUG | 10118 #ifdef DEBUG |
10181 graph_->Verify(false); // No full verify. | 10119 graph_->Verify(false); // No full verify. |
10182 #endif | 10120 #endif |
10183 } | 10121 } |
10184 | 10122 |
10185 } } // namespace v8::internal | 10123 } } // namespace v8::internal |
OLD | NEW |