Commit 6046e4a1 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Remove verbose escape analysis helper methods.

This is a pure refactoring that removes unnecessary wrapper methods from
the EscapeAnalysis class. This completely removes the notion of "Alias"
from the interface.

R=jarin@chromium.org

Review-Url: https://codereview.chromium.org/1989243002
Cr-Commit-Position: refs/heads/master@{#36325}
parent d5aa995e
...@@ -24,7 +24,7 @@ namespace v8 { ...@@ -24,7 +24,7 @@ namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
using Alias = EscapeAnalysis::Alias; typedef NodeId Alias;
#ifdef DEBUG #ifdef DEBUG
#define TRACE(...) \ #define TRACE(...) \
...@@ -1092,8 +1092,8 @@ void EscapeAnalysis::ProcessAllocationUsers(Node* node) { ...@@ -1092,8 +1092,8 @@ void EscapeAnalysis::ProcessAllocationUsers(Node* node) {
if (!obj->AllFieldsClear()) { if (!obj->AllFieldsClear()) {
obj = CopyForModificationAt(obj, state, node); obj = CopyForModificationAt(obj, state, node);
obj->ClearAllFields(); obj->ClearAllFields();
TRACE("Cleared all fields of @%d:#%d\n", GetAlias(obj->id()), TRACE("Cleared all fields of @%d:#%d\n",
obj->id()); status_analysis_->GetAlias(obj->id()), obj->id());
} }
} }
break; break;
...@@ -1119,7 +1119,7 @@ VirtualObject* EscapeAnalysis::CopyForModificationAt(VirtualObject* obj, ...@@ -1119,7 +1119,7 @@ VirtualObject* EscapeAnalysis::CopyForModificationAt(VirtualObject* obj,
Node* node) { Node* node) {
if (obj->NeedCopyForModification()) { if (obj->NeedCopyForModification()) {
state = CopyForModificationAt(state, node); state = CopyForModificationAt(state, node);
return state->Copy(obj, GetAlias(obj->id())); return state->Copy(obj, status_analysis_->GetAlias(obj->id()));
} }
return obj; return obj;
} }
...@@ -1160,7 +1160,7 @@ void EscapeAnalysis::ForwardVirtualState(Node* node) { ...@@ -1160,7 +1160,7 @@ void EscapeAnalysis::ForwardVirtualState(Node* node) {
void EscapeAnalysis::ProcessStart(Node* node) { void EscapeAnalysis::ProcessStart(Node* node) {
DCHECK_EQ(node->opcode(), IrOpcode::kStart); DCHECK_EQ(node->opcode(), IrOpcode::kStart);
virtual_states_[node->id()] = virtual_states_[node->id()] =
new (zone()) VirtualState(node, zone(), AliasCount()); new (zone()) VirtualState(node, zone(), status_analysis_->AliasCount());
} }
bool EscapeAnalysis::ProcessEffectPhi(Node* node) { bool EscapeAnalysis::ProcessEffectPhi(Node* node) {
...@@ -1169,7 +1169,8 @@ bool EscapeAnalysis::ProcessEffectPhi(Node* node) { ...@@ -1169,7 +1169,8 @@ bool EscapeAnalysis::ProcessEffectPhi(Node* node) {
VirtualState* mergeState = virtual_states_[node->id()]; VirtualState* mergeState = virtual_states_[node->id()];
if (!mergeState) { if (!mergeState) {
mergeState = new (zone()) VirtualState(node, zone(), AliasCount()); mergeState =
new (zone()) VirtualState(node, zone(), status_analysis_->AliasCount());
virtual_states_[node->id()] = mergeState; virtual_states_[node->id()] = mergeState;
changed = true; changed = true;
TRACE("Effect Phi #%d got new virtual state %p.\n", node->id(), TRACE("Effect Phi #%d got new virtual state %p.\n", node->id(),
...@@ -1187,7 +1188,8 @@ bool EscapeAnalysis::ProcessEffectPhi(Node* node) { ...@@ -1187,7 +1188,8 @@ bool EscapeAnalysis::ProcessEffectPhi(Node* node) {
if (state) { if (state) {
cache_->states().push_back(state); cache_->states().push_back(state);
if (state == mergeState) { if (state == mergeState) {
mergeState = new (zone()) VirtualState(node, zone(), AliasCount()); mergeState = new (zone())
VirtualState(node, zone(), status_analysis_->AliasCount());
virtual_states_[node->id()] = mergeState; virtual_states_[node->id()] = mergeState;
changed = true; changed = true;
} }
...@@ -1216,7 +1218,7 @@ void EscapeAnalysis::ProcessAllocation(Node* node) { ...@@ -1216,7 +1218,7 @@ void EscapeAnalysis::ProcessAllocation(Node* node) {
DCHECK_EQ(node->opcode(), IrOpcode::kAllocate); DCHECK_EQ(node->opcode(), IrOpcode::kAllocate);
ForwardVirtualState(node); ForwardVirtualState(node);
VirtualState* state = virtual_states_[node->id()]; VirtualState* state = virtual_states_[node->id()];
Alias alias = GetAlias(node->id()); Alias alias = status_analysis_->GetAlias(node->id());
// Check if we have already processed this node. // Check if we have already processed this node.
if (state->VirtualObjectFromAlias(alias)) { if (state->VirtualObjectFromAlias(alias)) {
...@@ -1248,19 +1250,16 @@ void EscapeAnalysis::ProcessFinishRegion(Node* node) { ...@@ -1248,19 +1250,16 @@ void EscapeAnalysis::ProcessFinishRegion(Node* node) {
Node* allocation = NodeProperties::GetValueInput(node, 0); Node* allocation = NodeProperties::GetValueInput(node, 0);
if (allocation->opcode() == IrOpcode::kAllocate) { if (allocation->opcode() == IrOpcode::kAllocate) {
VirtualState* state = virtual_states_[node->id()]; VirtualState* state = virtual_states_[node->id()];
VirtualObject* obj = state->VirtualObjectFromAlias(GetAlias(node->id())); VirtualObject* obj =
state->VirtualObjectFromAlias(status_analysis_->GetAlias(node->id()));
DCHECK_NOT_NULL(obj); DCHECK_NOT_NULL(obj);
obj->SetInitialized(); obj->SetInitialized();
} }
} }
Node* EscapeAnalysis::replacement(NodeId id) {
if (id >= replacements_.size()) return nullptr;
return replacements_[id];
}
Node* EscapeAnalysis::replacement(Node* node) { Node* EscapeAnalysis::replacement(Node* node) {
return replacement(node->id()); if (node->id() >= replacements_.size()) return nullptr;
return replacements_[node->id()];
} }
bool EscapeAnalysis::SetReplacement(Node* node, Node* rep) { bool EscapeAnalysis::SetReplacement(Node* node, Node* rep) {
...@@ -1291,16 +1290,11 @@ Node* EscapeAnalysis::ResolveReplacement(Node* node) { ...@@ -1291,16 +1290,11 @@ Node* EscapeAnalysis::ResolveReplacement(Node* node) {
} }
Node* EscapeAnalysis::GetReplacement(Node* node) { Node* EscapeAnalysis::GetReplacement(Node* node) {
return GetReplacement(node->id()); Node* result = nullptr;
} while (replacement(node)) {
node = result = replacement(node);
Node* EscapeAnalysis::GetReplacement(NodeId id) {
Node* node = nullptr;
while (replacement(id)) {
node = replacement(id);
id = node->id();
} }
return node; return result;
} }
bool EscapeAnalysis::IsVirtual(Node* node) { bool EscapeAnalysis::IsVirtual(Node* node) {
...@@ -1317,17 +1311,6 @@ bool EscapeAnalysis::IsEscaped(Node* node) { ...@@ -1317,17 +1311,6 @@ bool EscapeAnalysis::IsEscaped(Node* node) {
return status_analysis_->IsEscaped(node); return status_analysis_->IsEscaped(node);
} }
bool EscapeAnalysis::SetEscaped(Node* node) {
return status_analysis_->SetEscaped(node);
}
VirtualObject* EscapeAnalysis::GetVirtualObject(Node* at, NodeId id) {
if (VirtualState* states = virtual_states_[at->id()]) {
return states->VirtualObjectFromAlias(GetAlias(id));
}
return nullptr;
}
bool EscapeAnalysis::CompareVirtualObjects(Node* left, Node* right) { bool EscapeAnalysis::CompareVirtualObjects(Node* left, Node* right) {
DCHECK(IsVirtual(left) && IsVirtual(right)); DCHECK(IsVirtual(left) && IsVirtual(right));
left = ResolveReplacement(left); left = ResolveReplacement(left);
...@@ -1445,7 +1428,7 @@ void EscapeAnalysis::ProcessLoadElement(Node* node) { ...@@ -1445,7 +1428,7 @@ void EscapeAnalysis::ProcessLoadElement(Node* node) {
} }
} else { } else {
// We have a load from a non-const index, cannot eliminate object. // We have a load from a non-const index, cannot eliminate object.
if (SetEscaped(from)) { if (status_analysis_->SetEscaped(from)) {
TRACE( TRACE(
"Setting #%d (%s) to escaped because load element #%d from non-const " "Setting #%d (%s) to escaped because load element #%d from non-const "
"index #%d (%s)\n", "index #%d (%s)\n",
...@@ -1500,7 +1483,7 @@ void EscapeAnalysis::ProcessStoreElement(Node* node) { ...@@ -1500,7 +1483,7 @@ void EscapeAnalysis::ProcessStoreElement(Node* node) {
} }
} else { } else {
// We have a store to a non-const index, cannot eliminate object. // We have a store to a non-const index, cannot eliminate object.
if (SetEscaped(to)) { if (status_analysis_->SetEscaped(to)) {
TRACE( TRACE(
"Setting #%d (%s) to escaped because store element #%d to non-const " "Setting #%d (%s) to escaped because store element #%d to non-const "
"index #%d (%s)\n", "index #%d (%s)\n",
...@@ -1511,8 +1494,8 @@ void EscapeAnalysis::ProcessStoreElement(Node* node) { ...@@ -1511,8 +1494,8 @@ void EscapeAnalysis::ProcessStoreElement(Node* node) {
if (!obj->AllFieldsClear()) { if (!obj->AllFieldsClear()) {
obj = CopyForModificationAt(obj, state, node); obj = CopyForModificationAt(obj, state, node);
obj->ClearAllFields(); obj->ClearAllFields();
TRACE("Cleared all fields of @%d:#%d\n", GetAlias(obj->id()), TRACE("Cleared all fields of @%d:#%d\n",
obj->id()); status_analysis_->GetAlias(obj->id()), obj->id());
} }
} }
} }
...@@ -1560,7 +1543,10 @@ Node* EscapeAnalysis::GetOrCreateObjectState(Node* effect, Node* node) { ...@@ -1560,7 +1543,10 @@ Node* EscapeAnalysis::GetOrCreateObjectState(Node* effect, Node* node) {
return nullptr; return nullptr;
} }
void EscapeAnalysis::DebugPrintObject(VirtualObject* object, Alias alias) { void EscapeAnalysis::DebugPrintState(VirtualState* state) {
PrintF("Dumping virtual state %p\n", static_cast<void*>(state));
for (Alias alias = 0; alias < status_analysis_->AliasCount(); ++alias) {
if (VirtualObject* object = state->VirtualObjectFromAlias(alias)) {
PrintF(" Alias @%d: Object #%d with %zu fields\n", alias, object->id(), PrintF(" Alias @%d: Object #%d with %zu fields\n", alias, object->id(),
object->field_count()); object->field_count());
for (size_t i = 0; i < object->field_count(); ++i) { for (size_t i = 0; i < object->field_count(); ++i) {
...@@ -1568,13 +1554,6 @@ void EscapeAnalysis::DebugPrintObject(VirtualObject* object, Alias alias) { ...@@ -1568,13 +1554,6 @@ void EscapeAnalysis::DebugPrintObject(VirtualObject* object, Alias alias) {
PrintF(" Field %zu = #%d (%s)\n", i, f->id(), f->op()->mnemonic()); PrintF(" Field %zu = #%d (%s)\n", i, f->id(), f->op()->mnemonic());
} }
} }
}
void EscapeAnalysis::DebugPrintState(VirtualState* state) {
PrintF("Dumping virtual state %p\n", static_cast<void*>(state));
for (Alias alias = 0; alias < AliasCount(); ++alias) {
if (VirtualObject* object = state->VirtualObjectFromAlias(alias)) {
DebugPrintObject(object, alias);
} }
} }
} }
...@@ -1597,14 +1576,14 @@ void EscapeAnalysis::DebugPrint() { ...@@ -1597,14 +1576,14 @@ void EscapeAnalysis::DebugPrint() {
VirtualObject* EscapeAnalysis::GetVirtualObject(VirtualState* state, VirtualObject* EscapeAnalysis::GetVirtualObject(VirtualState* state,
Node* node) { Node* node) {
if (node->id() >= status_analysis_->GetAliasMap().size()) return nullptr; if (node->id() >= status_analysis_->GetAliasMap().size()) return nullptr;
Alias alias = GetAlias(node->id()); Alias alias = status_analysis_->GetAlias(node->id());
if (alias >= state->size()) return nullptr; if (alias >= state->size()) return nullptr;
return state->VirtualObjectFromAlias(alias); return state->VirtualObjectFromAlias(alias);
} }
bool EscapeAnalysis::ExistsVirtualAllocate() { bool EscapeAnalysis::ExistsVirtualAllocate() {
for (size_t id = 0; id < status_analysis_->GetAliasMap().size(); ++id) { for (size_t id = 0; id < status_analysis_->GetAliasMap().size(); ++id) {
Alias alias = GetAlias(static_cast<NodeId>(id)); Alias alias = status_analysis_->GetAlias(static_cast<NodeId>(id));
if (alias < EscapeStatusAnalysis::kUntrackable) { if (alias < EscapeStatusAnalysis::kUntrackable) {
if (status_analysis_->IsVirtual(static_cast<int>(id))) { if (status_analysis_->IsVirtual(static_cast<int>(id))) {
return true; return true;
...@@ -1614,14 +1593,6 @@ bool EscapeAnalysis::ExistsVirtualAllocate() { ...@@ -1614,14 +1593,6 @@ bool EscapeAnalysis::ExistsVirtualAllocate() {
return false; return false;
} }
Alias EscapeAnalysis::GetAlias(NodeId id) const {
return status_analysis_->GetAlias(id);
}
Alias EscapeAnalysis::AliasCount() const {
return status_analysis_->AliasCount();
}
Graph* EscapeAnalysis::graph() const { return status_analysis_->graph(); } Graph* EscapeAnalysis::graph() const { return status_analysis_->graph(); }
} // namespace compiler } // namespace compiler
......
...@@ -22,7 +22,6 @@ class VirtualObject; ...@@ -22,7 +22,6 @@ class VirtualObject;
// an object is virtual and eliminated. // an object is virtual and eliminated.
class EscapeAnalysis { class EscapeAnalysis {
public: public:
typedef NodeId Alias;
EscapeAnalysis(Graph* graph, CommonOperatorBuilder* common, Zone* zone); EscapeAnalysis(Graph* graph, CommonOperatorBuilder* common, Zone* zone);
~EscapeAnalysis(); ~EscapeAnalysis();
...@@ -56,13 +55,9 @@ class EscapeAnalysis { ...@@ -56,13 +55,9 @@ class EscapeAnalysis {
VirtualState* CopyForModificationAt(VirtualState* state, Node* node); VirtualState* CopyForModificationAt(VirtualState* state, Node* node);
VirtualObject* CopyForModificationAt(VirtualObject* obj, VirtualState* state, VirtualObject* CopyForModificationAt(VirtualObject* obj, VirtualState* state,
Node* node); Node* node);
VirtualObject* GetVirtualObject(Node* at, NodeId id);
bool SetEscaped(Node* node);
Node* replacement(NodeId id);
Node* replacement(Node* node); Node* replacement(Node* node);
Node* ResolveReplacement(Node* node); Node* ResolveReplacement(Node* node);
Node* GetReplacement(NodeId id);
bool SetReplacement(Node* node, Node* rep); bool SetReplacement(Node* node, Node* rep);
bool UpdateReplacement(VirtualState* state, Node* node, Node* rep); bool UpdateReplacement(VirtualState* state, Node* node, Node* rep);
...@@ -70,10 +65,6 @@ class EscapeAnalysis { ...@@ -70,10 +65,6 @@ class EscapeAnalysis {
void DebugPrint(); void DebugPrint();
void DebugPrintState(VirtualState* state); void DebugPrintState(VirtualState* state);
void DebugPrintObject(VirtualObject* state, Alias id);
Alias GetAlias(NodeId id) const;
Alias AliasCount() const;
Graph* graph() const; Graph* graph() const;
Zone* zone() const { return zone_; } Zone* zone() const { return zone_; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment