| 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 19 matching lines...) Expand all Loading... |
| 30 #include <algorithm> | 30 #include <algorithm> |
| 31 | 31 |
| 32 #include "v8.h" | 32 #include "v8.h" |
| 33 #include "codegen.h" | 33 #include "codegen.h" |
| 34 #include "full-codegen.h" | 34 #include "full-codegen.h" |
| 35 #include "hashmap.h" | 35 #include "hashmap.h" |
| 36 #include "hydrogen-dce.h" | 36 #include "hydrogen-dce.h" |
| 37 #include "hydrogen-environment-liveness.h" | 37 #include "hydrogen-environment-liveness.h" |
| 38 #include "hydrogen-escape-analysis.h" | 38 #include "hydrogen-escape-analysis.h" |
| 39 #include "hydrogen-infer-representation.h" | 39 #include "hydrogen-infer-representation.h" |
| 40 #include "hydrogen-infer-types.h" |
| 40 #include "hydrogen-gvn.h" | 41 #include "hydrogen-gvn.h" |
| 41 #include "hydrogen-osr.h" | 42 #include "hydrogen-osr.h" |
| 42 #include "hydrogen-range-analysis.h" | 43 #include "hydrogen-range-analysis.h" |
| 43 #include "hydrogen-sce.h" | 44 #include "hydrogen-sce.h" |
| 44 #include "hydrogen-uint32-analysis.h" | 45 #include "hydrogen-uint32-analysis.h" |
| 45 #include "lithium-allocator.h" | 46 #include "lithium-allocator.h" |
| 46 #include "parser.h" | 47 #include "parser.h" |
| 47 #include "scopeinfo.h" | 48 #include "scopeinfo.h" |
| 48 #include "scopes.h" | 49 #include "scopes.h" |
| 49 #include "stub-cache.h" | 50 #include "stub-cache.h" |
| (...skipping 2553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2603 phi_list_ = new(zone()) ZoneList<HPhi*>(block_count, zone()); | 2604 phi_list_ = new(zone()) ZoneList<HPhi*>(block_count, zone()); |
| 2604 for (int i = 0; i < block_count; ++i) { | 2605 for (int i = 0; i < block_count; ++i) { |
| 2605 for (int j = 0; j < blocks_[i]->phis()->length(); ++j) { | 2606 for (int j = 0; j < blocks_[i]->phis()->length(); ++j) { |
| 2606 HPhi* phi = blocks_[i]->phis()->at(j); | 2607 HPhi* phi = blocks_[i]->phis()->at(j); |
| 2607 phi_list_->Add(phi, zone()); | 2608 phi_list_->Add(phi, zone()); |
| 2608 } | 2609 } |
| 2609 } | 2610 } |
| 2610 } | 2611 } |
| 2611 | 2612 |
| 2612 | 2613 |
| 2613 void HGraph::InferTypes(ZoneList<HValue*>* worklist) { | |
| 2614 BitVector in_worklist(GetMaximumValueID(), zone()); | |
| 2615 for (int i = 0; i < worklist->length(); ++i) { | |
| 2616 ASSERT(!in_worklist.Contains(worklist->at(i)->id())); | |
| 2617 in_worklist.Add(worklist->at(i)->id()); | |
| 2618 } | |
| 2619 | |
| 2620 while (!worklist->is_empty()) { | |
| 2621 HValue* current = worklist->RemoveLast(); | |
| 2622 in_worklist.Remove(current->id()); | |
| 2623 if (current->UpdateInferredType()) { | |
| 2624 for (HUseIterator it(current->uses()); !it.Done(); it.Advance()) { | |
| 2625 HValue* use = it.value(); | |
| 2626 if (!in_worklist.Contains(use->id())) { | |
| 2627 in_worklist.Add(use->id()); | |
| 2628 worklist->Add(use, zone()); | |
| 2629 } | |
| 2630 } | |
| 2631 } | |
| 2632 } | |
| 2633 } | |
| 2634 | |
| 2635 | |
| 2636 void HGraph::MergeRemovableSimulates() { | 2614 void HGraph::MergeRemovableSimulates() { |
| 2637 HPhase phase("H_Merge removable simulates", this); | 2615 HPhase phase("H_Merge removable simulates", this); |
| 2638 ZoneList<HSimulate*> mergelist(2, zone()); | 2616 ZoneList<HSimulate*> mergelist(2, zone()); |
| 2639 for (int i = 0; i < blocks()->length(); ++i) { | 2617 for (int i = 0; i < blocks()->length(); ++i) { |
| 2640 HBasicBlock* block = blocks()->at(i); | 2618 HBasicBlock* block = blocks()->at(i); |
| 2641 // Make sure the merge list is empty at the start of a block. | 2619 // Make sure the merge list is empty at the start of a block. |
| 2642 ASSERT(mergelist.is_empty()); | 2620 ASSERT(mergelist.is_empty()); |
| 2643 // Nasty heuristic: Never remove the first simulate in a block. This | 2621 // Nasty heuristic: Never remove the first simulate in a block. This |
| 2644 // just so happens to have a beneficial effect on register allocation. | 2622 // just so happens to have a beneficial effect on register allocation. |
| 2645 bool first = true; | 2623 bool first = true; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2689 | 2667 |
| 2690 if (!mergelist.is_empty()) { | 2668 if (!mergelist.is_empty()) { |
| 2691 // Merge the accumulated simulates at the end of the block. | 2669 // Merge the accumulated simulates at the end of the block. |
| 2692 HSimulate* last = mergelist.RemoveLast(); | 2670 HSimulate* last = mergelist.RemoveLast(); |
| 2693 last->MergeWith(&mergelist); | 2671 last->MergeWith(&mergelist); |
| 2694 } | 2672 } |
| 2695 } | 2673 } |
| 2696 } | 2674 } |
| 2697 | 2675 |
| 2698 | 2676 |
| 2699 void HGraph::InitializeInferredTypes() { | |
| 2700 HPhase phase("H_Inferring types", this); | |
| 2701 InitializeInferredTypes(0, this->blocks_.length() - 1); | |
| 2702 } | |
| 2703 | |
| 2704 | |
| 2705 void HGraph::InitializeInferredTypes(int from_inclusive, int to_inclusive) { | |
| 2706 for (int i = from_inclusive; i <= to_inclusive; ++i) { | |
| 2707 HBasicBlock* block = blocks_[i]; | |
| 2708 | |
| 2709 const ZoneList<HPhi*>* phis = block->phis(); | |
| 2710 for (int j = 0; j < phis->length(); j++) { | |
| 2711 phis->at(j)->UpdateInferredType(); | |
| 2712 } | |
| 2713 | |
| 2714 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { | |
| 2715 it.Current()->UpdateInferredType(); | |
| 2716 } | |
| 2717 | |
| 2718 if (block->IsLoopHeader()) { | |
| 2719 HBasicBlock* last_back_edge = | |
| 2720 block->loop_information()->GetLastBackEdge(); | |
| 2721 InitializeInferredTypes(i + 1, last_back_edge->block_id()); | |
| 2722 // Skip all blocks already processed by the recursive call. | |
| 2723 i = last_back_edge->block_id(); | |
| 2724 // Update phis of the loop header now after the whole loop body is | |
| 2725 // guaranteed to be processed. | |
| 2726 ZoneList<HValue*> worklist(block->phis()->length(), zone()); | |
| 2727 for (int j = 0; j < block->phis()->length(); ++j) { | |
| 2728 worklist.Add(block->phis()->at(j), zone()); | |
| 2729 } | |
| 2730 InferTypes(&worklist); | |
| 2731 } | |
| 2732 } | |
| 2733 } | |
| 2734 | |
| 2735 | |
| 2736 void HGraph::PropagateMinusZeroChecks(HValue* value, BitVector* visited) { | 2677 void HGraph::PropagateMinusZeroChecks(HValue* value, BitVector* visited) { |
| 2737 HValue* current = value; | 2678 HValue* current = value; |
| 2738 while (current != NULL) { | 2679 while (current != NULL) { |
| 2739 if (visited->Contains(current->id())) return; | 2680 if (visited->Contains(current->id())) return; |
| 2740 | 2681 |
| 2741 // For phis, we must propagate the check to all of its inputs. | 2682 // For phis, we must propagate the check to all of its inputs. |
| 2742 if (current->IsPhi()) { | 2683 if (current->IsPhi()) { |
| 2743 visited->Add(current->id()); | 2684 visited->Add(current->id()); |
| 2744 HPhi* phi = HPhi::cast(current); | 2685 HPhi* phi = HPhi::cast(current); |
| 2745 for (int i = 0; i < phi->OperandCount(); ++i) { | 2686 for (int i = 0; i < phi->OperandCount(); ++i) { |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3433 Run<HInferRepresentationPhase>(); | 3374 Run<HInferRepresentationPhase>(); |
| 3434 | 3375 |
| 3435 // Remove HSimulate instructions that have turned out not to be needed | 3376 // Remove HSimulate instructions that have turned out not to be needed |
| 3436 // after all by folding them into the following HSimulate. | 3377 // after all by folding them into the following HSimulate. |
| 3437 // This must happen after inferring representations. | 3378 // This must happen after inferring representations. |
| 3438 MergeRemovableSimulates(); | 3379 MergeRemovableSimulates(); |
| 3439 | 3380 |
| 3440 MarkDeoptimizeOnUndefined(); | 3381 MarkDeoptimizeOnUndefined(); |
| 3441 InsertRepresentationChanges(); | 3382 InsertRepresentationChanges(); |
| 3442 | 3383 |
| 3443 InitializeInferredTypes(); | 3384 Run<HInferTypesPhase>(); |
| 3444 | 3385 |
| 3445 // Must be performed before canonicalization to ensure that Canonicalize | 3386 // Must be performed before canonicalization to ensure that Canonicalize |
| 3446 // will not remove semantically meaningful ToInt32 operations e.g. BIT_OR with | 3387 // will not remove semantically meaningful ToInt32 operations e.g. BIT_OR with |
| 3447 // zero. | 3388 // zero. |
| 3448 if (FLAG_opt_safe_uint32_operations) Run<HUint32AnalysisPhase>(); | 3389 if (FLAG_opt_safe_uint32_operations) Run<HUint32AnalysisPhase>(); |
| 3449 | 3390 |
| 3450 if (FLAG_use_canonicalizing) Canonicalize(); | 3391 if (FLAG_use_canonicalizing) Canonicalize(); |
| 3451 | 3392 |
| 3452 if (FLAG_use_escape_analysis) Run<HEscapeAnalysisPhase>(); | 3393 if (FLAG_use_escape_analysis) Run<HEscapeAnalysisPhase>(); |
| 3453 | 3394 |
| (...skipping 7246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10700 if (ShouldProduceTraceOutput()) { | 10641 if (ShouldProduceTraceOutput()) { |
| 10701 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 10642 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 10702 } | 10643 } |
| 10703 | 10644 |
| 10704 #ifdef DEBUG | 10645 #ifdef DEBUG |
| 10705 graph_->Verify(false); // No full verify. | 10646 graph_->Verify(false); // No full verify. |
| 10706 #endif | 10647 #endif |
| 10707 } | 10648 } |
| 10708 | 10649 |
| 10709 } } // namespace v8::internal | 10650 } } // namespace v8::internal |
| OLD | NEW |