Index: src/hydrogen-escape-analysis.cc |
diff --git a/src/hydrogen-escape-analysis.cc b/src/hydrogen-escape-analysis.cc |
index 102301992333e1c9a994d0d7b051577869ac89fa..3b00866e650f7bdcd9d8783ff680bb221041abba 100644 |
--- a/src/hydrogen-escape-analysis.cc |
+++ b/src/hydrogen-escape-analysis.cc |
@@ -161,6 +161,27 @@ HValue* HEscapeAnalysisPhase::NewMapCheckAndInsert(HCapturedObject* state, |
} |
+// Replace a field load with a given value, forcing Smi representation if |
+// necessary. |
+void HEscapeAnalysisPhase::ReplaceFieldLoadWithValue( |
+ HLoadNamedField* load, HValue* load_value) { |
+ HValue* replacement = load_value; |
+ Representation representation = load->representation(); |
+ if (representation.IsSmi()) { |
+ Zone* zone = graph()->zone(); |
+ HInstruction* new_instr = |
+ HForceRepresentation::New(zone, NULL, load_value, representation); |
+ new_instr->InsertAfter(load); |
+ replacement = new_instr; |
+ } |
+ load->DeleteAndReplaceWith(replacement); |
Michael Starzinger
2014/04/25 11:08:09
nit: I was actually thinking along the lines of ha
|
+ if (FLAG_trace_escape_analysis) { |
+ PrintF("Replacing load #%d with #%d (%s)\n", load->id(), |
+ replacement->id(), replacement->Mnemonic()); |
+ } |
+} |
+ |
+ |
// 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 |
@@ -196,12 +217,7 @@ void HEscapeAnalysisPhase::AnalyzeDataFlow(HInstruction* allocate) { |
int index = load->access().offset() / kPointerSize; |
if (load->object() != allocate) continue; |
ASSERT(load->access().IsInobject()); |
- HValue* replacement = state->OperandAt(index); |
- load->DeleteAndReplaceWith(replacement); |
- if (FLAG_trace_escape_analysis) { |
- PrintF("Replacing load #%d with #%d (%s)\n", instr->id(), |
- replacement->id(), replacement->Mnemonic()); |
- } |
+ ReplaceFieldLoadWithValue(load, state->OperandAt(index)); |
break; |
} |
case HValue::kStoreNamedField: { |