| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/escape-analysis.h" | 5 #include "src/compiler/escape-analysis.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "src/base/flags.h" | 9 #include "src/base/flags.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 case IrOpcode::kStoreElement: | 687 case IrOpcode::kStoreElement: |
| 688 ProcessStoreElement(node); | 688 ProcessStoreElement(node); |
| 689 break; | 689 break; |
| 690 case IrOpcode::kLoadField: | 690 case IrOpcode::kLoadField: |
| 691 case IrOpcode::kLoadElement: { | 691 case IrOpcode::kLoadElement: { |
| 692 if (Node* rep = object_analysis_->GetReplacement(node)) { | 692 if (Node* rep = object_analysis_->GetReplacement(node)) { |
| 693 if (IsAllocation(rep) && CheckUsesForEscape(node, rep)) { | 693 if (IsAllocation(rep) && CheckUsesForEscape(node, rep)) { |
| 694 RevisitInputs(rep); | 694 RevisitInputs(rep); |
| 695 RevisitUses(rep); | 695 RevisitUses(rep); |
| 696 } | 696 } |
| 697 } else { |
| 698 Node* from = NodeProperties::GetValueInput(node, 0); |
| 699 from = object_analysis_->ResolveReplacement(from); |
| 700 if (SetEscaped(from)) { |
| 701 TRACE("Setting #%d (%s) to escaped because of unresolved load #%i\n", |
| 702 from->id(), from->op()->mnemonic(), node->id()); |
| 703 RevisitInputs(from); |
| 704 RevisitUses(from); |
| 705 } |
| 697 } | 706 } |
| 698 RevisitUses(node); | 707 RevisitUses(node); |
| 699 break; | 708 break; |
| 700 } | 709 } |
| 701 case IrOpcode::kPhi: | 710 case IrOpcode::kPhi: |
| 702 if (!HasEntry(node)) { | 711 if (!HasEntry(node)) { |
| 703 status_[node->id()] |= kTracked; | 712 status_[node->id()] |= kTracked; |
| 704 RevisitUses(node); | 713 RevisitUses(node); |
| 705 } | 714 } |
| 706 if (!IsAllocationPhi(node) && SetEscaped(node)) { | 715 if (!IsAllocationPhi(node) && SetEscaped(node)) { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 replacements_(zone), | 900 replacements_(zone), |
| 892 cycle_detection_(zone), | 901 cycle_detection_(zone), |
| 893 cache_(nullptr) { | 902 cache_(nullptr) { |
| 894 // Type slot_not_analyzed_ manually. | 903 // Type slot_not_analyzed_ manually. |
| 895 double v = OpParameter<double>(slot_not_analyzed_); | 904 double v = OpParameter<double>(slot_not_analyzed_); |
| 896 NodeProperties::SetType(slot_not_analyzed_, Type::Range(v, v, zone)); | 905 NodeProperties::SetType(slot_not_analyzed_, Type::Range(v, v, zone)); |
| 897 } | 906 } |
| 898 | 907 |
| 899 EscapeAnalysis::~EscapeAnalysis() {} | 908 EscapeAnalysis::~EscapeAnalysis() {} |
| 900 | 909 |
| 901 void EscapeAnalysis::Run() { | 910 bool EscapeAnalysis::Run() { |
| 902 replacements_.resize(graph()->NodeCount()); | 911 replacements_.resize(graph()->NodeCount()); |
| 903 status_analysis_->AssignAliases(); | 912 status_analysis_->AssignAliases(); |
| 904 if (status_analysis_->AliasCount() > 0) { | 913 if (status_analysis_->AliasCount() > 0) { |
| 905 cache_ = new (zone()) MergeCache(zone()); | 914 cache_ = new (zone()) MergeCache(zone()); |
| 906 replacements_.resize(graph()->NodeCount()); | 915 replacements_.resize(graph()->NodeCount()); |
| 907 status_analysis_->ResizeStatusVector(); | 916 status_analysis_->ResizeStatusVector(); |
| 908 RunObjectAnalysis(); | 917 RunObjectAnalysis(); |
| 909 status_analysis_->RunStatusAnalysis(); | 918 status_analysis_->RunStatusAnalysis(); |
| 919 return true; |
| 920 } else { |
| 921 return false; |
| 910 } | 922 } |
| 911 } | 923 } |
| 912 | 924 |
| 913 void EscapeStatusAnalysis::AssignAliases() { | 925 void EscapeStatusAnalysis::AssignAliases() { |
| 914 size_t max_size = 1024; | 926 size_t max_size = 1024; |
| 915 size_t min_size = 32; | 927 size_t min_size = 32; |
| 916 size_t stack_size = | 928 size_t stack_size = |
| 917 std::min(std::max(graph()->NodeCount() / 5, min_size), max_size); | 929 std::min(std::max(graph()->NodeCount() / 5, min_size), max_size); |
| 918 stack_.reserve(stack_size); | 930 stack_.reserve(stack_size); |
| 919 ResizeStatusVector(); | 931 ResizeStatusVector(); |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1736 } | 1748 } |
| 1737 } | 1749 } |
| 1738 return false; | 1750 return false; |
| 1739 } | 1751 } |
| 1740 | 1752 |
| 1741 Graph* EscapeAnalysis::graph() const { return status_analysis_->graph(); } | 1753 Graph* EscapeAnalysis::graph() const { return status_analysis_->graph(); } |
| 1742 | 1754 |
| 1743 } // namespace compiler | 1755 } // namespace compiler |
| 1744 } // namespace internal | 1756 } // namespace internal |
| 1745 } // namespace v8 | 1757 } // namespace v8 |
| OLD | NEW |