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 "src/base/flags.h" | 7 #include "src/base/flags.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 if (FLAG_trace_turbo_escape && ls->GetField(i)) { | 278 if (FLAG_trace_turbo_escape && ls->GetField(i)) { |
279 PrintF(" Field %zu agree on rep #%d\n", i, | 279 PrintF(" Field %zu agree on rep #%d\n", i, |
280 ls->GetField(i)->id()); | 280 ls->GetField(i)->id()); |
281 } | 281 } |
282 } else if (ls->GetField(i) != nullptr && rs->GetField(i) != nullptr) { | 282 } else if (ls->GetField(i) != nullptr && rs->GetField(i) != nullptr) { |
283 Node* rep = mergeObject->GetField(i); | 283 Node* rep = mergeObject->GetField(i); |
284 if (!rep || rep->opcode() != IrOpcode::kPhi || | 284 if (!rep || rep->opcode() != IrOpcode::kPhi || |
285 NodeProperties::GetValueInput(rep, 0) != ls->GetField(i) || | 285 NodeProperties::GetValueInput(rep, 0) != ls->GetField(i) || |
286 NodeProperties::GetValueInput(rep, 1) != rs->GetField(i)) { | 286 NodeProperties::GetValueInput(rep, 1) != rs->GetField(i)) { |
287 Node* phi = | 287 Node* phi = |
288 graph->NewNode(common->Phi(kMachAnyTagged, 2), ls->GetField(i), | 288 graph->NewNode(common->Phi(MachineRepresentation::kTagged, 2), |
289 rs->GetField(i), control); | 289 ls->GetField(i), rs->GetField(i), control); |
290 if (mergeObject->SetField(i, phi)) { | 290 if (mergeObject->SetField(i, phi)) { |
291 if (FLAG_trace_turbo_escape) { | 291 if (FLAG_trace_turbo_escape) { |
292 PrintF(" Creating Phi #%d as merge of #%d and #%d\n", | 292 PrintF(" Creating Phi #%d as merge of #%d and #%d\n", |
293 phi->id(), ls->GetField(i)->id(), rs->GetField(i)->id()); | 293 phi->id(), ls->GetField(i)->id(), rs->GetField(i)->id()); |
294 } | 294 } |
295 changed = true; | 295 changed = true; |
296 } | 296 } |
297 } else { | 297 } else { |
298 if (FLAG_trace_turbo_escape) { | 298 if (FLAG_trace_turbo_escape) { |
299 PrintF(" Retaining Phi #%d as merge of #%d and #%d\n", | 299 PrintF(" Retaining Phi #%d as merge of #%d and #%d\n", |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 Node* rv = r->GetField(offset); | 945 Node* rv = r->GetField(offset); |
946 if (lv && rv) { | 946 if (lv && rv) { |
947 if (!state->GetVirtualObject(node)) { | 947 if (!state->GetVirtualObject(node)) { |
948 state->SetVirtualObject(node->id(), | 948 state->SetVirtualObject(node->id(), |
949 new (zone()) VirtualObject(node->id(), zone())); | 949 new (zone()) VirtualObject(node->id(), zone())); |
950 } | 950 } |
951 Node* rep = state->GetVirtualObject(node)->GetReplacement(); | 951 Node* rep = state->GetVirtualObject(node)->GetReplacement(); |
952 if (!rep || rep->opcode() != IrOpcode::kPhi || | 952 if (!rep || rep->opcode() != IrOpcode::kPhi || |
953 NodeProperties::GetValueInput(rep, 0) != lv || | 953 NodeProperties::GetValueInput(rep, 0) != lv || |
954 NodeProperties::GetValueInput(rep, 1) != rv) { | 954 NodeProperties::GetValueInput(rep, 1) != rv) { |
955 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), lv, rv, | 955 Node* phi = |
956 NodeProperties::GetControlInput(from)); | 956 graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), |
| 957 lv, rv, NodeProperties::GetControlInput(from)); |
957 state->GetVirtualObject(node)->SetReplacement(phi); | 958 state->GetVirtualObject(node)->SetReplacement(phi); |
958 state->LastChangedAt(node); | 959 state->LastChangedAt(node); |
959 if (FLAG_trace_turbo_escape) { | 960 if (FLAG_trace_turbo_escape) { |
960 PrintF(" got phi of #%d is #%d created.\n", lv->id(), rv->id()); | 961 PrintF(" got phi of #%d is #%d created.\n", lv->id(), rv->id()); |
961 } | 962 } |
962 } else if (FLAG_trace_turbo_escape) { | 963 } else if (FLAG_trace_turbo_escape) { |
963 PrintF(" has already the right phi representation.\n"); | 964 PrintF(" has already the right phi representation.\n"); |
964 } | 965 } |
965 } else if (FLAG_trace_turbo_escape) { | 966 } else if (FLAG_trace_turbo_escape) { |
966 PrintF(" has incomplete field info: %p %p\n", static_cast<void*>(lv), | 967 PrintF(" has incomplete field info: %p %p\n", static_cast<void*>(lv), |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 | 1002 |
1002 void EscapeAnalysis::ProcessLoadElement(Node* node) { | 1003 void EscapeAnalysis::ProcessLoadElement(Node* node) { |
1003 DCHECK_EQ(node->opcode(), IrOpcode::kLoadElement); | 1004 DCHECK_EQ(node->opcode(), IrOpcode::kLoadElement); |
1004 ForwardVirtualState(node); | 1005 ForwardVirtualState(node); |
1005 Node* from = NodeProperties::GetValueInput(node, 0); | 1006 Node* from = NodeProperties::GetValueInput(node, 0); |
1006 VirtualState* state = virtual_states_[node->id()]; | 1007 VirtualState* state = virtual_states_[node->id()]; |
1007 if (VirtualObject* object = state->ResolveVirtualObject(from)) { | 1008 if (VirtualObject* object = state->ResolveVirtualObject(from)) { |
1008 NumberMatcher index(node->InputAt(1)); | 1009 NumberMatcher index(node->InputAt(1)); |
1009 ElementAccess access = OpParameter<ElementAccess>(node); | 1010 ElementAccess access = OpParameter<ElementAccess>(node); |
1010 if (index.HasValue()) { | 1011 if (index.HasValue()) { |
1011 CHECK_EQ(ElementSizeLog2Of(access.machine_type), kPointerSizeLog2); | 1012 CHECK_EQ(ElementSizeLog2Of(access.machine_type.representation()), |
| 1013 kPointerSizeLog2); |
1012 CHECK_EQ(access.header_size % kPointerSize, 0); | 1014 CHECK_EQ(access.header_size % kPointerSize, 0); |
1013 int offset = index.Value() + access.header_size / kPointerSize; | 1015 int offset = index.Value() + access.header_size / kPointerSize; |
1014 if (!object->IsTracked()) return; | 1016 if (!object->IsTracked()) return; |
1015 Node* value = object->GetField(offset); | 1017 Node* value = object->GetField(offset); |
1016 if (value) { | 1018 if (value) { |
1017 value = state->ResolveReplacement(value); | 1019 value = state->ResolveReplacement(value); |
1018 // Record that the load has this alias. | 1020 // Record that the load has this alias. |
1019 state->UpdateReplacement(node, value, zone()); | 1021 state->UpdateReplacement(node, value, zone()); |
1020 } else if (FLAG_trace_turbo_escape) { | 1022 } else if (FLAG_trace_turbo_escape) { |
1021 PrintF("No field %d on record for #%d\n", offset, from->id()); | 1023 PrintF("No field %d on record for #%d\n", offset, from->id()); |
(...skipping 29 matching lines...) Expand all Loading... |
1051 | 1053 |
1052 | 1054 |
1053 void EscapeAnalysis::ProcessStoreElement(Node* node) { | 1055 void EscapeAnalysis::ProcessStoreElement(Node* node) { |
1054 DCHECK_EQ(node->opcode(), IrOpcode::kStoreElement); | 1056 DCHECK_EQ(node->opcode(), IrOpcode::kStoreElement); |
1055 ForwardVirtualState(node); | 1057 ForwardVirtualState(node); |
1056 Node* to = NodeProperties::GetValueInput(node, 0); | 1058 Node* to = NodeProperties::GetValueInput(node, 0); |
1057 NumberMatcher index(node->InputAt(1)); | 1059 NumberMatcher index(node->InputAt(1)); |
1058 ElementAccess access = OpParameter<ElementAccess>(node); | 1060 ElementAccess access = OpParameter<ElementAccess>(node); |
1059 Node* val = NodeProperties::GetValueInput(node, 2); | 1061 Node* val = NodeProperties::GetValueInput(node, 2); |
1060 if (index.HasValue()) { | 1062 if (index.HasValue()) { |
1061 CHECK_EQ(ElementSizeLog2Of(access.machine_type), kPointerSizeLog2); | 1063 CHECK_EQ(ElementSizeLog2Of(access.machine_type.representation()), |
| 1064 kPointerSizeLog2); |
1062 CHECK_EQ(access.header_size % kPointerSize, 0); | 1065 CHECK_EQ(access.header_size % kPointerSize, 0); |
1063 int offset = index.Value() + access.header_size / kPointerSize; | 1066 int offset = index.Value() + access.header_size / kPointerSize; |
1064 VirtualState* states = virtual_states_[node->id()]; | 1067 VirtualState* states = virtual_states_[node->id()]; |
1065 if (VirtualObject* obj = states->ResolveVirtualObject(to)) { | 1068 if (VirtualObject* obj = states->ResolveVirtualObject(to)) { |
1066 if (!obj->IsTracked()) return; | 1069 if (!obj->IsTracked()) return; |
1067 if (obj->SetField(offset, states->ResolveReplacement(val))) { | 1070 if (obj->SetField(offset, states->ResolveReplacement(val))) { |
1068 states->LastChangedAt(node); | 1071 states->LastChangedAt(node); |
1069 } | 1072 } |
1070 } | 1073 } |
1071 } | 1074 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 } | 1114 } |
1112 } | 1115 } |
1113 for (size_t n = 0; n < object_states.size(); n++) { | 1116 for (size_t n = 0; n < object_states.size(); n++) { |
1114 DebugPrintState(object_states[n]); | 1117 DebugPrintState(object_states[n]); |
1115 } | 1118 } |
1116 } | 1119 } |
1117 | 1120 |
1118 } // namespace compiler | 1121 } // namespace compiler |
1119 } // namespace internal | 1122 } // namespace internal |
1120 } // namespace v8 | 1123 } // namespace v8 |
OLD | NEW |