Chromium Code Reviews| Index: src/hydrogen-escape-analysis.cc |
| diff --git a/src/hydrogen-escape-analysis.cc b/src/hydrogen-escape-analysis.cc |
| index 311091b6d993ddf78f7b373309d60b6869a249e7..b72f8a78a09c54588dee242c3735ee0b3d3f587f 100644 |
| --- a/src/hydrogen-escape-analysis.cc |
| +++ b/src/hydrogen-escape-analysis.cc |
| @@ -124,6 +124,21 @@ HPhi* HEscapeAnalysisPhase::NewPhiAndInsert( |
| } |
| +// Insert a newly created value check as a replacement for map checks. |
| +HValue* HEscapeAnalysisPhase::NewMapCheckAndInsert( |
| + HCapturedObject* state, HCheckMaps* mapcheck) { |
|
Toon Verwaest
2013/08/28 13:29:30
Syntax nit: each argument on a single line.
Michael Starzinger
2013/08/28 13:53:15
Done. Also for the other methods above.
|
| + Zone* zone = graph()->zone(); |
| + HValue* value = state->values()->first(); |
|
Toon Verwaest
2013/08/28 13:29:30
Can we have a helper method map_value() on HCaptur
Michael Starzinger
2013/08/28 13:53:15
Done.
|
| + // TODO(mstarzinger): This will narrow a map check against a set of maps |
| + // down to the first element in the set. Revisit and fix this. |
| + Handle<Map> map_object = mapcheck->map_set()->first(); |
| + UniqueValueId map_id = mapcheck->map_unique_ids()->first(); |
| + HCheckValue* check = HCheckValue::New(zone, NULL, value, map_object, map_id); |
| + check->InsertBefore(mapcheck); |
| + return check; |
| +} |
| + |
| + |
| // Performs a forward data-flow analysis of all loads and stores on the |
| // given captured allocation. This uses a reverse post-order iteration |
| // over affected basic blocks. All non-escaping instructions are handled |
| @@ -177,7 +192,7 @@ void HEscapeAnalysisPhase::AnalyzeDataFlow(HInstruction* allocate) { |
| if (store->has_transition()) { |
| state->SetOperandAt(0, store->transition()); |
| } |
| - store->DeleteAndReplaceWith(NULL); |
| + store->DeleteAndReplaceWith(store->ActualValue()); |
| if (FLAG_trace_escape_analysis) { |
| PrintF("Replacing store #%d%s\n", instr->id(), |
| store->has_transition() ? " (with transition)" : ""); |
| @@ -196,15 +211,13 @@ void HEscapeAnalysisPhase::AnalyzeDataFlow(HInstruction* allocate) { |
| case HValue::kCheckHeapObject: { |
| HCheckHeapObject* check = HCheckHeapObject::cast(instr); |
| if (check->value() != allocate) continue; |
| - check->DeleteAndReplaceWith(NULL); |
| + check->DeleteAndReplaceWith(check->ActualValue()); |
| break; |
| } |
| case HValue::kCheckMaps: { |
| HCheckMaps* mapcheck = HCheckMaps::cast(instr); |
| if (mapcheck->value() != allocate) continue; |
| - // TODO(mstarzinger): This approach breaks if the tracked map value |
| - // is not a HConstant. Find a repro test case and fix this. |
| - ASSERT(mapcheck->ActualValue() == allocate); |
| + NewMapCheckAndInsert(state, mapcheck); |
| mapcheck->DeleteAndReplaceWith(mapcheck->ActualValue()); |
| break; |
| } |