Commit 288d3812 authored by tebbi's avatar tebbi Committed by Commit bot

[turbofan] Fixed reuse of nested ObjectState in escape analysis

The problem is that writes to nested objects do not lead to a copy of a referencing VirtualObject, and that each VirtualObjects maintains a cache of an ObjectState node. Together, this leads to inappropriate reuse of ObjectState nodes.
This fix simply always copies all virtual objects when a new VirtualState is created. This is clearly not optimal to avoid clones, but determining precisely which virtual objects are affected by a write is a transitive closure computation on the virtual objects of a virtual state. Alternatively, one could change the semantics of the node cache.

BUG=v8:5611

Review-Url: https://codereview.chromium.org/2488713002
Cr-Commit-Position: refs/heads/master@{#40854}
parent 8d6de5f2
......@@ -1135,7 +1135,17 @@ VirtualObject* EscapeAnalysis::CopyForModificationAt(VirtualObject* obj,
Node* node) {
if (obj->NeedCopyForModification()) {
state = CopyForModificationAt(state, node);
return state->Copy(obj, status_analysis_->GetAlias(obj->id()));
// TODO(tebbi): this copies the complete virtual state. Replace with a more
// precise analysis of which objects are actually affected by the change.
Alias changed_alias = status_analysis_->GetAlias(obj->id());
for (Alias alias = 0; alias < state->size(); ++alias) {
if (VirtualObject* next_obj = state->VirtualObjectFromAlias(alias)) {
if (alias != changed_alias && next_obj->NeedCopyForModification()) {
state->Copy(next_obj, alias);
}
}
}
return state->Copy(obj, changed_alias);
}
return obj;
}
......
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