Commit 43905141 authored by sigurds's avatar sigurds Committed by Commit bot

[turbofan] Escape Analysis improvements

Move replacements out of virtual object. Replacements are
global to the graph and are not dependent on the virtual
state (after they are discovered).

R=mstarzinger@chromium.org
BUG=v8:4586
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#32838}
parent a0f7cafa
......@@ -49,7 +49,7 @@ Reduction EscapeAnalysisReducer::Reduce(Node* node) {
Reduction EscapeAnalysisReducer::ReduceLoad(Node* node) {
DCHECK(node->opcode() == IrOpcode::kLoadField ||
node->opcode() == IrOpcode::kLoadElement);
if (Node* rep = escape_analysis()->GetReplacement(node, node->id())) {
if (Node* rep = escape_analysis()->GetReplacement(node)) {
if (FLAG_trace_turbo_escape) {
PrintF("Replaced #%d (%s) with #%d (%s)\n", node->id(),
node->op()->mnemonic(), rep->id(), rep->op()->mnemonic());
......@@ -116,10 +116,10 @@ Reduction EscapeAnalysisReducer::ReduceReferenceEqual(Node* node) {
Node* right = NodeProperties::GetValueInput(node, 1);
if (escape_analysis()->IsVirtual(left)) {
if (escape_analysis()->IsVirtual(right)) {
if (Node* rep = escape_analysis()->GetReplacement(node, left->id())) {
if (Node* rep = escape_analysis()->GetReplacement(left)) {
left = rep;
}
if (Node* rep = escape_analysis()->GetReplacement(node, right->id())) {
if (Node* rep = escape_analysis()->GetReplacement(right)) {
right = rep;
}
// TODO(sigurds): What to do if either is a PHI?
......
This diff is collapsed.
......@@ -107,7 +107,7 @@ class EscapeAnalysis {
void Run();
Node* GetReplacement(Node* at, NodeId id);
Node* GetReplacement(Node* node);
bool IsVirtual(Node* node);
bool IsEscaped(Node* node);
......@@ -134,8 +134,16 @@ class EscapeAnalysis {
int OffsetFromAccess(Node* node);
VirtualObject* GetVirtualObject(Node* at, NodeId id);
VirtualObject* ResolveVirtualObject(VirtualState* state, Node* node);
Node* GetReplacementIfSame(ZoneVector<VirtualObject*>& objs);
bool SetEscaped(Node* node);
Node* replacement(NodeId id);
Node* replacement(Node* node);
Node* ResolveReplacement(Node* node);
Node* GetReplacement(NodeId id);
bool SetReplacement(Node* node, Node* rep);
bool UpdateReplacement(VirtualState* state, Node* node, Node* rep);
void DebugPrint();
void DebugPrintState(VirtualState* state);
......@@ -149,6 +157,7 @@ class EscapeAnalysis {
CommonOperatorBuilder* const common_;
Zone* const zone_;
ZoneVector<VirtualState*> virtual_states_;
ZoneVector<Node*> replacements_;
EscapeStatusAnalysis escape_status_;
MergeCache cache_;
......
......@@ -140,11 +140,11 @@ class EscapeAnalysisTest : public GraphTest {
// ---------------------------------Assertion Helper--------------------------
void ExpectReplacement(Node* node, Node* rep) {
EXPECT_EQ(rep, escape_analysis()->GetReplacement(node, node->id()));
EXPECT_EQ(rep, escape_analysis()->GetReplacement(node));
}
void ExpectReplacementPhi(Node* node, Node* left, Node* right) {
Node* rep = escape_analysis()->GetReplacement(node, node->id());
Node* rep = escape_analysis()->GetReplacement(node);
ASSERT_NE(nullptr, rep);
ASSERT_EQ(IrOpcode::kPhi, rep->opcode());
EXPECT_EQ(left, NodeProperties::GetValueInput(rep, 0));
......@@ -270,7 +270,7 @@ TEST_F(EscapeAnalysisTest, BranchNonEscape) {
ExpectVirtual(allocation);
ExpectReplacementPhi(load, object1, object2);
Node* replacement_phi = escape_analysis()->GetReplacement(load, load->id());
Node* replacement_phi = escape_analysis()->GetReplacement(load);
Transformation();
......
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