Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/compiler/escape-analysis.cc

Issue 2704573003: Revert of [turbofan] extend escape analysis to reduce CheckMaps (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/escape-analysis.h ('k') | src/compiler/escape-analysis-reducer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 case IrOpcode::kStoreElement: 680 case IrOpcode::kStoreElement:
681 ProcessStoreElement(node); 681 ProcessStoreElement(node);
682 break; 682 break;
683 case IrOpcode::kLoadField: 683 case IrOpcode::kLoadField:
684 case IrOpcode::kLoadElement: { 684 case IrOpcode::kLoadElement: {
685 if (Node* rep = object_analysis_->GetReplacement(node)) { 685 if (Node* rep = object_analysis_->GetReplacement(node)) {
686 if (IsAllocation(rep) && CheckUsesForEscape(node, rep)) { 686 if (IsAllocation(rep) && CheckUsesForEscape(node, rep)) {
687 RevisitInputs(rep); 687 RevisitInputs(rep);
688 RevisitUses(rep); 688 RevisitUses(rep);
689 } 689 }
690 } else {
691 Node* from = NodeProperties::GetValueInput(node, 0);
692 if (SetEscaped(from)) {
693 TRACE("Setting #%d (%s) to escaped because of unresolved load #%i\n",
694 from->id(), from->op()->mnemonic(), node->id());
695 RevisitInputs(from);
696 RevisitUses(from);
697 }
698 } 690 }
699
700 RevisitUses(node); 691 RevisitUses(node);
701 break; 692 break;
702 } 693 }
703 case IrOpcode::kPhi: 694 case IrOpcode::kPhi:
704 if (!HasEntry(node)) { 695 if (!HasEntry(node)) {
705 status_[node->id()] |= kTracked; 696 status_[node->id()] |= kTracked;
706 RevisitUses(node); 697 RevisitUses(node);
707 } 698 }
708 if (!IsAllocationPhi(node) && SetEscaped(node)) { 699 if (!IsAllocationPhi(node) && SetEscaped(node)) {
709 RevisitInputs(node); 700 RevisitInputs(node);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 } 784 }
794 // Fallthrough. 785 // Fallthrough.
795 case IrOpcode::kStoreField: 786 case IrOpcode::kStoreField:
796 case IrOpcode::kLoadField: 787 case IrOpcode::kLoadField:
797 case IrOpcode::kStoreElement: 788 case IrOpcode::kStoreElement:
798 case IrOpcode::kLoadElement: 789 case IrOpcode::kLoadElement:
799 case IrOpcode::kFrameState: 790 case IrOpcode::kFrameState:
800 case IrOpcode::kStateValues: 791 case IrOpcode::kStateValues:
801 case IrOpcode::kReferenceEqual: 792 case IrOpcode::kReferenceEqual:
802 case IrOpcode::kFinishRegion: 793 case IrOpcode::kFinishRegion:
803 case IrOpcode::kCheckMaps:
804 if (IsEscaped(use) && SetEscaped(rep)) { 794 if (IsEscaped(use) && SetEscaped(rep)) {
805 TRACE( 795 TRACE(
806 "Setting #%d (%s) to escaped because of use by escaping node " 796 "Setting #%d (%s) to escaped because of use by escaping node "
807 "#%d (%s)\n", 797 "#%d (%s)\n",
808 rep->id(), rep->op()->mnemonic(), use->id(), 798 rep->id(), rep->op()->mnemonic(), use->id(),
809 use->op()->mnemonic()); 799 use->op()->mnemonic());
810 return true; 800 return true;
811 } 801 }
812 break; 802 break;
813 case IrOpcode::kObjectIsSmi: 803 case IrOpcode::kObjectIsSmi:
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 replacements_(zone), 884 replacements_(zone),
895 cycle_detection_(zone), 885 cycle_detection_(zone),
896 cache_(nullptr) { 886 cache_(nullptr) {
897 // Type slot_not_analyzed_ manually. 887 // Type slot_not_analyzed_ manually.
898 double v = OpParameter<double>(slot_not_analyzed_); 888 double v = OpParameter<double>(slot_not_analyzed_);
899 NodeProperties::SetType(slot_not_analyzed_, Type::Range(v, v, zone)); 889 NodeProperties::SetType(slot_not_analyzed_, Type::Range(v, v, zone));
900 } 890 }
901 891
902 EscapeAnalysis::~EscapeAnalysis() {} 892 EscapeAnalysis::~EscapeAnalysis() {}
903 893
904 bool EscapeAnalysis::Run() { 894 void EscapeAnalysis::Run() {
905 replacements_.resize(graph()->NodeCount()); 895 replacements_.resize(graph()->NodeCount());
906 status_analysis_->AssignAliases(); 896 status_analysis_->AssignAliases();
907 if (status_analysis_->AliasCount() > 0) { 897 if (status_analysis_->AliasCount() > 0) {
908 cache_ = new (zone()) MergeCache(zone()); 898 cache_ = new (zone()) MergeCache(zone());
909 replacements_.resize(graph()->NodeCount()); 899 replacements_.resize(graph()->NodeCount());
910 status_analysis_->ResizeStatusVector(); 900 status_analysis_->ResizeStatusVector();
911 RunObjectAnalysis(); 901 RunObjectAnalysis();
912 status_analysis_->RunStatusAnalysis(); 902 status_analysis_->RunStatusAnalysis();
913 return true;
914 } else {
915 return false;
916 } 903 }
917 } 904 }
918 905
919 void EscapeStatusAnalysis::AssignAliases() { 906 void EscapeStatusAnalysis::AssignAliases() {
920 size_t max_size = 1024; 907 size_t max_size = 1024;
921 size_t min_size = 32; 908 size_t min_size = 32;
922 size_t stack_size = 909 size_t stack_size =
923 std::min(std::max(graph()->NodeCount() / 5, min_size), max_size); 910 std::min(std::max(graph()->NodeCount() / 5, min_size), max_size);
924 stack_.reserve(stack_size); 911 stack_.reserve(stack_size);
925 ResizeStatusVector(); 912 ResizeStatusVector();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 break; 1098 break;
1112 case IrOpcode::kLoadField: 1099 case IrOpcode::kLoadField:
1113 ProcessLoadField(node); 1100 ProcessLoadField(node);
1114 break; 1101 break;
1115 case IrOpcode::kStoreElement: 1102 case IrOpcode::kStoreElement:
1116 ProcessStoreElement(node); 1103 ProcessStoreElement(node);
1117 break; 1104 break;
1118 case IrOpcode::kLoadElement: 1105 case IrOpcode::kLoadElement:
1119 ProcessLoadElement(node); 1106 ProcessLoadElement(node);
1120 break; 1107 break;
1121 case IrOpcode::kCheckMaps:
1122 ProcessCheckMaps(node);
1123 break;
1124 case IrOpcode::kStart: 1108 case IrOpcode::kStart:
1125 ProcessStart(node); 1109 ProcessStart(node);
1126 break; 1110 break;
1127 case IrOpcode::kEffectPhi: 1111 case IrOpcode::kEffectPhi:
1128 return ProcessEffectPhi(node); 1112 return ProcessEffectPhi(node);
1129 break; 1113 break;
1130 default: 1114 default:
1131 if (node->op()->EffectInputCount() > 0) { 1115 if (node->op()->EffectInputCount() > 0) {
1132 ForwardVirtualState(node); 1116 ForwardVirtualState(node);
1133 } 1117 }
(...skipping 17 matching lines...) Expand all
1151 case IrOpcode::kStoreField: 1135 case IrOpcode::kStoreField:
1152 case IrOpcode::kLoadField: 1136 case IrOpcode::kLoadField:
1153 case IrOpcode::kStoreElement: 1137 case IrOpcode::kStoreElement:
1154 case IrOpcode::kLoadElement: 1138 case IrOpcode::kLoadElement:
1155 case IrOpcode::kFrameState: 1139 case IrOpcode::kFrameState:
1156 case IrOpcode::kStateValues: 1140 case IrOpcode::kStateValues:
1157 case IrOpcode::kReferenceEqual: 1141 case IrOpcode::kReferenceEqual:
1158 case IrOpcode::kFinishRegion: 1142 case IrOpcode::kFinishRegion:
1159 case IrOpcode::kObjectIsSmi: 1143 case IrOpcode::kObjectIsSmi:
1160 break; 1144 break;
1161 case IrOpcode::kCheckMaps: {
1162 CheckMapsParameters params = CheckMapsParametersOf(node->op());
1163 if (params.flags() == CheckMapsFlag::kNone) break;
1164 } // Fallthrough.
1165 default: 1145 default:
1166 VirtualState* state = virtual_states_[node->id()]; 1146 VirtualState* state = virtual_states_[node->id()];
1167 if (VirtualObject* obj = 1147 if (VirtualObject* obj =
1168 GetVirtualObject(state, ResolveReplacement(input))) { 1148 GetVirtualObject(state, ResolveReplacement(input))) {
1169 if (!obj->AllFieldsClear()) { 1149 if (!obj->AllFieldsClear()) {
1170 obj = CopyForModificationAt(obj, state, node); 1150 obj = CopyForModificationAt(obj, state, node);
1171 obj->ClearAllFields(); 1151 obj->ClearAllFields();
1172 TRACE("Cleared all fields of @%d:#%d\n", 1152 TRACE("Cleared all fields of @%d:#%d\n",
1173 status_analysis_->GetAlias(obj->id()), obj->id()); 1153 status_analysis_->GetAlias(obj->id()), obj->id());
1174 } 1154 }
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 } else if (from->opcode() == IrOpcode::kPhi && 1488 } else if (from->opcode() == IrOpcode::kPhi &&
1509 IsOffsetForFieldAccessCorrect(FieldAccessOf(node->op()))) { 1489 IsOffsetForFieldAccessCorrect(FieldAccessOf(node->op()))) {
1510 int offset = OffsetForFieldAccess(node); 1490 int offset = OffsetForFieldAccess(node);
1511 // Only binary phis are supported for now. 1491 // Only binary phis are supported for now.
1512 ProcessLoadFromPhi(offset, from, node, state); 1492 ProcessLoadFromPhi(offset, from, node, state);
1513 } else { 1493 } else {
1514 UpdateReplacement(state, node, nullptr); 1494 UpdateReplacement(state, node, nullptr);
1515 } 1495 }
1516 } 1496 }
1517 1497
1518 void EscapeAnalysis::ProcessCheckMaps(Node* node) {
1519 DCHECK_EQ(node->opcode(), IrOpcode::kCheckMaps);
1520 ForwardVirtualState(node);
1521 Node* checked = ResolveReplacement(NodeProperties::GetValueInput(node, 0));
1522 VirtualState* state = virtual_states_[node->id()];
1523 if (VirtualObject* object = GetVirtualObject(state, checked)) {
1524 if (!object->IsTracked()) {
1525 if (status_analysis_->SetEscaped(node)) {
1526 TRACE(
1527 "Setting #%d (%s) to escaped because checked object #%i is not "
1528 "tracked\n",
1529 node->id(), node->op()->mnemonic(), object->id());
1530 }
1531 return;
1532 }
1533 CheckMapsParameters params = CheckMapsParametersOf(node->op());
1534
1535 Node* value = object->GetField(HeapObject::kMapOffset / kPointerSize);
1536 if (value) {
1537 value = ResolveReplacement(value);
1538 // TODO(tebbi): We want to extend this beyond constant folding with a
1539 // CheckMapsValue operator that takes the load-eliminated map value as
1540 // input.
1541 if (value->opcode() == IrOpcode::kHeapConstant &&
1542 params.maps().contains(ZoneHandleSet<Map>(
1543 Handle<Map>::cast(OpParameter<Handle<HeapObject>>(value))))) {
1544 TRACE("CheckMaps #%i seems to be redundant (until now).\n", node->id());
1545 return;
1546 }
1547 }
1548 }
1549 if (status_analysis_->SetEscaped(node)) {
1550 TRACE("Setting #%d (%s) to escaped (checking #%i)\n", node->id(),
1551 node->op()->mnemonic(), checked->id());
1552 }
1553 }
1554
1555 void EscapeAnalysis::ProcessLoadElement(Node* node) { 1498 void EscapeAnalysis::ProcessLoadElement(Node* node) {
1556 DCHECK_EQ(node->opcode(), IrOpcode::kLoadElement); 1499 DCHECK_EQ(node->opcode(), IrOpcode::kLoadElement);
1557 ForwardVirtualState(node); 1500 ForwardVirtualState(node);
1558 Node* from = ResolveReplacement(NodeProperties::GetValueInput(node, 0)); 1501 Node* from = ResolveReplacement(NodeProperties::GetValueInput(node, 0));
1559 VirtualState* state = virtual_states_[node->id()]; 1502 VirtualState* state = virtual_states_[node->id()];
1560 Node* index_node = node->InputAt(1); 1503 Node* index_node = node->InputAt(1);
1561 NumberMatcher index(index_node); 1504 NumberMatcher index(index_node);
1562 DCHECK(index_node->opcode() != IrOpcode::kInt32Constant && 1505 DCHECK(index_node->opcode() != IrOpcode::kInt32Constant &&
1563 index_node->opcode() != IrOpcode::kInt64Constant && 1506 index_node->opcode() != IrOpcode::kInt64Constant &&
1564 index_node->opcode() != IrOpcode::kFloat32Constant && 1507 index_node->opcode() != IrOpcode::kFloat32Constant &&
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 } 1729 }
1787 } 1730 }
1788 return false; 1731 return false;
1789 } 1732 }
1790 1733
1791 Graph* EscapeAnalysis::graph() const { return status_analysis_->graph(); } 1734 Graph* EscapeAnalysis::graph() const { return status_analysis_->graph(); }
1792 1735
1793 } // namespace compiler 1736 } // namespace compiler
1794 } // namespace internal 1737 } // namespace internal
1795 } // namespace v8 1738 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/escape-analysis.h ('k') | src/compiler/escape-analysis-reducer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698