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 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 if (status_[id] & kTracked) { | 842 if (status_[id] & kTracked) { |
843 PrintF("Node #%d is %s\n", id, | 843 PrintF("Node #%d is %s\n", id, |
844 (status_[id] & kEscaped) ? "escaping" : "virtual"); | 844 (status_[id] & kEscaped) ? "escaping" : "virtual"); |
845 } | 845 } |
846 } | 846 } |
847 } | 847 } |
848 | 848 |
849 EscapeAnalysis::EscapeAnalysis(Graph* graph, CommonOperatorBuilder* common, | 849 EscapeAnalysis::EscapeAnalysis(Graph* graph, CommonOperatorBuilder* common, |
850 Zone* zone) | 850 Zone* zone) |
851 : zone_(zone), | 851 : zone_(zone), |
| 852 slot_not_analyzed_(graph->NewNode(common->NumberConstant(0x1c0debad))), |
852 common_(common), | 853 common_(common), |
853 status_analysis_(new (zone) EscapeStatusAnalysis(this, graph, zone)), | 854 status_analysis_(new (zone) EscapeStatusAnalysis(this, graph, zone)), |
854 virtual_states_(zone), | 855 virtual_states_(zone), |
855 replacements_(zone), | 856 replacements_(zone), |
856 cache_(nullptr) {} | 857 cache_(nullptr) {} |
857 | 858 |
858 EscapeAnalysis::~EscapeAnalysis() {} | 859 EscapeAnalysis::~EscapeAnalysis() {} |
859 | 860 |
860 void EscapeAnalysis::Run() { | 861 void EscapeAnalysis::Run() { |
861 replacements_.resize(graph()->NodeCount()); | 862 replacements_.resize(graph()->NodeCount()); |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1453 void EscapeAnalysis::ProcessStoreField(Node* node) { | 1454 void EscapeAnalysis::ProcessStoreField(Node* node) { |
1454 DCHECK_EQ(node->opcode(), IrOpcode::kStoreField); | 1455 DCHECK_EQ(node->opcode(), IrOpcode::kStoreField); |
1455 ForwardVirtualState(node); | 1456 ForwardVirtualState(node); |
1456 Node* to = ResolveReplacement(NodeProperties::GetValueInput(node, 0)); | 1457 Node* to = ResolveReplacement(NodeProperties::GetValueInput(node, 0)); |
1457 VirtualState* state = virtual_states_[node->id()]; | 1458 VirtualState* state = virtual_states_[node->id()]; |
1458 VirtualObject* obj = GetVirtualObject(state, to); | 1459 VirtualObject* obj = GetVirtualObject(state, to); |
1459 int offset = OffsetForFieldAccess(node); | 1460 int offset = OffsetForFieldAccess(node); |
1460 if (obj && obj->IsTracked() && | 1461 if (obj && obj->IsTracked() && |
1461 static_cast<size_t>(offset) < obj->field_count()) { | 1462 static_cast<size_t>(offset) < obj->field_count()) { |
1462 Node* val = ResolveReplacement(NodeProperties::GetValueInput(node, 1)); | 1463 Node* val = ResolveReplacement(NodeProperties::GetValueInput(node, 1)); |
| 1464 // TODO(mstarzinger): The following is a workaround to not track the code |
| 1465 // entry field in virtual JSFunction objects. We only ever store the inner |
| 1466 // pointer into the compile lazy stub in this field and the deoptimizer has |
| 1467 // this assumption hard-coded in {TranslatedState::MaterializeAt} as well. |
| 1468 if (val->opcode() == IrOpcode::kInt32Constant || |
| 1469 val->opcode() == IrOpcode::kInt64Constant) { |
| 1470 DCHECK_EQ(JSFunction::kCodeEntryOffset, FieldAccessOf(node->op()).offset); |
| 1471 val = slot_not_analyzed_; |
| 1472 } |
1463 if (obj->GetField(offset) != val) { | 1473 if (obj->GetField(offset) != val) { |
1464 obj = CopyForModificationAt(obj, state, node); | 1474 obj = CopyForModificationAt(obj, state, node); |
1465 obj->SetField(offset, val); | 1475 obj->SetField(offset, val); |
1466 } | 1476 } |
1467 } | 1477 } |
1468 } | 1478 } |
1469 | 1479 |
1470 void EscapeAnalysis::ProcessStoreElement(Node* node) { | 1480 void EscapeAnalysis::ProcessStoreElement(Node* node) { |
1471 DCHECK_EQ(node->opcode(), IrOpcode::kStoreElement); | 1481 DCHECK_EQ(node->opcode(), IrOpcode::kStoreElement); |
1472 ForwardVirtualState(node); | 1482 ForwardVirtualState(node); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1599 } | 1609 } |
1600 } | 1610 } |
1601 return false; | 1611 return false; |
1602 } | 1612 } |
1603 | 1613 |
1604 Graph* EscapeAnalysis::graph() const { return status_analysis_->graph(); } | 1614 Graph* EscapeAnalysis::graph() const { return status_analysis_->graph(); } |
1605 | 1615 |
1606 } // namespace compiler | 1616 } // namespace compiler |
1607 } // namespace internal | 1617 } // namespace internal |
1608 } // namespace v8 | 1618 } // namespace v8 |
OLD | NEW |