Commit 07cc8d59 authored by sigurds's avatar sigurds Committed by Commit bot

[turbofan] Fix ASAN bug in escape analysis

BUG=566253
LOG=n

Review URL: https://codereview.chromium.org/1530143002

Cr-Commit-Position: refs/heads/master@{#32942}
parent 2fb30320
...@@ -390,17 +390,16 @@ bool VirtualState::MergeFrom(MergeCache* cache, Zone* zone, Graph* graph, ...@@ -390,17 +390,16 @@ bool VirtualState::MergeFrom(MergeCache* cache, Zone* zone, Graph* graph,
graph->NewNode(common->Phi(MachineRepresentation::kTagged, 2), graph->NewNode(common->Phi(MachineRepresentation::kTagged, 2),
static_cast<int>(cache->fields().size()), static_cast<int>(cache->fields().size()),
&cache->fields().front()); &cache->fields().front());
if (mergeObject->SetField(i, phi, true)) { mergeObject->SetField(i, phi, true);
if (FLAG_trace_turbo_escape) { if (FLAG_trace_turbo_escape) {
PrintF(" Creating Phi #%d as merge of", phi->id()); PrintF(" Creating Phi #%d as merge of", phi->id());
for (size_t i = 0; i + 1 < cache->fields().size(); i++) { for (size_t i = 0; i + 1 < cache->fields().size(); i++) {
PrintF(" #%d (%s)", cache->fields()[i]->id(), PrintF(" #%d (%s)", cache->fields()[i]->id(),
cache->fields()[i]->op()->mnemonic()); cache->fields()[i]->op()->mnemonic());
}
PrintF("\n");
} }
changed = true; PrintF("\n");
} }
changed = true;
} else { } else {
DCHECK(rep->opcode() == IrOpcode::kPhi); DCHECK(rep->opcode() == IrOpcode::kPhi);
for (size_t n = 0; n < cache->fields().size(); ++n) { for (size_t n = 0; n < cache->fields().size(); ++n) {
...@@ -444,10 +443,8 @@ EscapeStatusAnalysis::EscapeStatusAnalysis(EscapeAnalysis* object_analysis, ...@@ -444,10 +443,8 @@ EscapeStatusAnalysis::EscapeStatusAnalysis(EscapeAnalysis* object_analysis,
: object_analysis_(object_analysis), : object_analysis_(object_analysis),
graph_(graph), graph_(graph),
zone_(zone), zone_(zone),
info_(zone), info_(graph->NodeCount(), kUnknown, zone),
queue_(zone) { queue_(zone) {}
info_.resize(graph->NodeCount());
}
EscapeStatusAnalysis::~EscapeStatusAnalysis() {} EscapeStatusAnalysis::~EscapeStatusAnalysis() {}
...@@ -459,9 +456,6 @@ bool EscapeStatusAnalysis::HasEntry(Node* node) { ...@@ -459,9 +456,6 @@ bool EscapeStatusAnalysis::HasEntry(Node* node) {
bool EscapeStatusAnalysis::IsVirtual(Node* node) { bool EscapeStatusAnalysis::IsVirtual(Node* node) {
if (node->id() >= info_.size()) {
return false;
}
return info_[node->id()] == kVirtual; return info_[node->id()] == kVirtual;
} }
...@@ -484,8 +478,16 @@ bool EscapeStatusAnalysis::SetEscaped(Node* node) { ...@@ -484,8 +478,16 @@ bool EscapeStatusAnalysis::SetEscaped(Node* node) {
} }
void EscapeStatusAnalysis::Resize() {
info_.resize(graph()->NodeCount(), kUnknown);
}
size_t EscapeStatusAnalysis::size() { return info_.size(); }
void EscapeStatusAnalysis::Run() { void EscapeStatusAnalysis::Run() {
info_.resize(graph()->NodeCount()); Resize();
ZoneVector<bool> visited(zone()); ZoneVector<bool> visited(zone());
visited.resize(graph()->NodeCount()); visited.resize(graph()->NodeCount());
queue_.push_back(graph()->end()); queue_.push_back(graph()->end());
...@@ -967,6 +969,7 @@ bool EscapeAnalysis::ProcessEffectPhi(Node* node) { ...@@ -967,6 +969,7 @@ bool EscapeAnalysis::ProcessEffectPhi(Node* node) {
if (changed) { if (changed) {
mergeState->LastChangedAt(node); mergeState->LastChangedAt(node);
escape_status_.Resize();
} }
return changed; return changed;
} }
...@@ -1072,11 +1075,17 @@ Node* EscapeAnalysis::GetReplacement(NodeId id) { ...@@ -1072,11 +1075,17 @@ Node* EscapeAnalysis::GetReplacement(NodeId id) {
bool EscapeAnalysis::IsVirtual(Node* node) { bool EscapeAnalysis::IsVirtual(Node* node) {
if (node->id() >= escape_status_.size()) {
return false;
}
return escape_status_.IsVirtual(node); return escape_status_.IsVirtual(node);
} }
bool EscapeAnalysis::IsEscaped(Node* node) { bool EscapeAnalysis::IsEscaped(Node* node) {
if (node->id() >= escape_status_.size()) {
return false;
}
return escape_status_.IsEscaped(node); return escape_status_.IsEscaped(node);
} }
...@@ -1133,6 +1142,7 @@ void EscapeAnalysis::ProcessLoadFromPhi(int offset, Node* from, Node* node, ...@@ -1133,6 +1142,7 @@ void EscapeAnalysis::ProcessLoadFromPhi(int offset, Node* from, Node* node,
Node* phi = graph()->NewNode( Node* phi = graph()->NewNode(
common()->Phi(MachineRepresentation::kTagged, 2), common()->Phi(MachineRepresentation::kTagged, 2),
static_cast<int>(cache_.fields().size()), &cache_.fields().front()); static_cast<int>(cache_.fields().size()), &cache_.fields().front());
escape_status_.Resize();
SetReplacement(node, phi); SetReplacement(node, phi);
state->LastChangedAt(node); state->LastChangedAt(node);
if (FLAG_trace_turbo_escape) { if (FLAG_trace_turbo_escape) {
......
...@@ -57,6 +57,8 @@ class EscapeStatusAnalysis { ...@@ -57,6 +57,8 @@ class EscapeStatusAnalysis {
void RevisitInputs(Node* node); void RevisitInputs(Node* node);
bool SetEscaped(Node* node); bool SetEscaped(Node* node);
bool HasEntry(Node* node); bool HasEntry(Node* node);
void Resize();
size_t size();
Graph* graph() const { return graph_; } Graph* graph() const { return graph_; }
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