Chromium Code Reviews| Index: src/compiler/escape-analysis.cc |
| diff --git a/src/compiler/escape-analysis.cc b/src/compiler/escape-analysis.cc |
| index 5dee0231d69d37307a21701fe0ad4a7d411665cf..fe745cc69bdd099573b474c48cb4878763fcfede 100644 |
| --- a/src/compiler/escape-analysis.cc |
| +++ b/src/compiler/escape-analysis.cc |
| @@ -432,13 +432,18 @@ void EscapeStatusAnalysis::DebugPrint() { |
| EscapeObjectAnalysis::EscapeObjectAnalysis(Graph* graph, |
| CommonOperatorBuilder* common, |
| Zone* zone) |
| - : graph_(graph), common_(common), zone_(zone), virtual_states_(zone) {} |
| + : graph_(graph), |
| + common_(common), |
| + zone_(zone), |
| + virtual_states_(zone), |
| + effects_(zone) {} |
| EscapeObjectAnalysis::~EscapeObjectAnalysis() {} |
| void EscapeObjectAnalysis::Run() { |
| + effects_.resize(graph()->NodeCount()); |
| virtual_states_.resize(graph()->NodeCount()); |
| ZoneVector<Node*> queue(zone()); |
| queue.push_back(graph()->start()); |
| @@ -485,6 +490,33 @@ bool EscapeObjectAnalysis::IsDanglingEffectNode(Node* node) { |
| } |
| +void EscapeObjectAnalysis::RecordEffectForFrameStateUses(Node* node, |
| + Node* effect) { |
| + DCHECK(effect->op()->EffectInputCount() > 0); |
| + ZoneVector<Node*> queue(zone()); |
| + queue.push_back(node); |
|
Jarin
2015/12/02 12:24:34
Nit: why is it called a queue when it is a stack?
sigurds
2015/12/02 16:35:12
Done.
|
| + while (!queue.empty()) { |
| + Node* cur = queue.back(); |
| + queue.pop_back(); |
| + for (Edge edge : cur->input_edges()) { |
| + Node* input = edge.to(); |
| + if (input->opcode() == IrOpcode::kFrameState || |
| + input->opcode() == IrOpcode::kStateValues) { |
| + if (effects_[input->id()] != effect) { |
| + effects_[input->id()] = effect; |
| + if (FLAG_trace_turbo_escape) { |
| + PrintF("Recorded effect #%d (%s) for frame state %d\n", |
| + effect->id(), effect->op()->mnemonic(), input->id()); |
| + } |
| + } |
| + // climb up the chain. |
| + queue.push_back(input); |
| + } |
| + } |
| + } |
| +} |
| + |
| + |
| bool EscapeObjectAnalysis::Process(Node* node) { |
| switch (node->opcode()) { |
| case IrOpcode::kAllocate: |
| @@ -511,6 +543,7 @@ bool EscapeObjectAnalysis::Process(Node* node) { |
| default: |
| if (node->op()->EffectInputCount() > 0) { |
| ForwardVirtualState(node); |
| + RecordEffectForFrameStateUses(node, node); |
| } |
| break; |
| } |
| @@ -678,6 +711,19 @@ Node* EscapeObjectAnalysis::GetReplacement(Node* at, NodeId id) { |
| } |
| +VirtualObject* EscapeObjectAnalysis::GetVirtualObject(Node* at, NodeId id) { |
| + if (VirtualState* states = virtual_states_[at->id()]) { |
| + return states->GetVirtualObject(id); |
| + } |
| + return nullptr; |
| +} |
| + |
| + |
| +Node* EscapeObjectAnalysis::GetEffect(Node* node) { |
| + return effects_[node->id()]; |
| +} |
| + |
| + |
| int EscapeObjectAnalysis::OffsetFromAccess(Node* node) { |
| DCHECK(OpParameter<FieldAccess>(node).offset % kPointerSize == 0); |
| return OpParameter<FieldAccess>(node).offset / kPointerSize; |