Fix escape analysis for redefining operators.

This recognizes escape paths that flow through informative definitions
as an escaping use. This only applies to HCheckMaps so far.

R=hpayer@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16420 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 899ec323
...@@ -31,21 +31,25 @@ namespace v8 { ...@@ -31,21 +31,25 @@ namespace v8 {
namespace internal { namespace internal {
void HEscapeAnalysisPhase::CollectIfNoEscapingUses(HInstruction* instr) { bool HEscapeAnalysisPhase::HasNoEscapingUses(HValue* value) {
for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { for (HUseIterator it(value->uses()); !it.Done(); it.Advance()) {
HValue* use = it.value(); HValue* use = it.value();
if (use->HasEscapingOperandAt(it.index())) { if (use->HasEscapingOperandAt(it.index())) {
if (FLAG_trace_escape_analysis) { if (FLAG_trace_escape_analysis) {
PrintF("#%d (%s) escapes through #%d (%s) @%d\n", instr->id(), PrintF("#%d (%s) escapes through #%d (%s) @%d\n", value->id(),
instr->Mnemonic(), use->id(), use->Mnemonic(), it.index()); value->Mnemonic(), use->id(), use->Mnemonic(), it.index());
} }
return; return false;
}
if (use->RedefinedOperandIndex() == it.index() && !HasNoEscapingUses(use)) {
if (FLAG_trace_escape_analysis) {
PrintF("#%d (%s) escapes redefinition #%d (%s) @%d\n", value->id(),
value->Mnemonic(), use->id(), use->Mnemonic(), it.index());
}
return false;
} }
} }
if (FLAG_trace_escape_analysis) { return true;
PrintF("#%d (%s) is being captured\n", instr->id(), instr->Mnemonic());
}
captured_.Add(instr, zone());
} }
...@@ -55,8 +59,12 @@ void HEscapeAnalysisPhase::CollectCapturedValues() { ...@@ -55,8 +59,12 @@ void HEscapeAnalysisPhase::CollectCapturedValues() {
HBasicBlock* block = graph()->blocks()->at(i); HBasicBlock* block = graph()->blocks()->at(i);
for (HInstructionIterator it(block); !it.Done(); it.Advance()) { for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
HInstruction* instr = it.Current(); HInstruction* instr = it.Current();
if (instr->IsAllocate()) { if (instr->IsAllocate() && HasNoEscapingUses(instr)) {
CollectIfNoEscapingUses(instr); if (FLAG_trace_escape_analysis) {
PrintF("#%d (%s) is being captured\n", instr->id(),
instr->Mnemonic());
}
captured_.Add(instr, zone());
} }
} }
} }
......
...@@ -52,7 +52,7 @@ class HEscapeAnalysisPhase : public HPhase { ...@@ -52,7 +52,7 @@ class HEscapeAnalysisPhase : public HPhase {
private: private:
void CollectCapturedValues(); void CollectCapturedValues();
void CollectIfNoEscapingUses(HInstruction* instr); bool HasNoEscapingUses(HValue* value);
void PerformScalarReplacement(); void PerformScalarReplacement();
void AnalyzeDataFlow(HInstruction* instr); void AnalyzeDataFlow(HInstruction* instr);
......
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