Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Unified Diff: src/hydrogen-escape-analysis.cc

Issue 251493004: Preserve Smi representation of non-escaping fields. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen-escape-analysis.h ('k') | test/mjsunit/regress/regress-escape-preserve-smi-representation.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen-escape-analysis.cc
diff --git a/src/hydrogen-escape-analysis.cc b/src/hydrogen-escape-analysis.cc
index 102301992333e1c9a994d0d7b051577869ac89fa..6a03c5773a42b5b251dc8b1009623b638f029224 100644
--- a/src/hydrogen-escape-analysis.cc
+++ b/src/hydrogen-escape-analysis.cc
@@ -161,6 +161,23 @@ HValue* HEscapeAnalysisPhase::NewMapCheckAndInsert(HCapturedObject* state,
}
+// Replace a field load with a given value, forcing Smi representation if
+// necessary.
+HValue* HEscapeAnalysisPhase::NewLoadReplacement(
+ 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;
+ }
+ return replacement;
+}
+
+
// 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,10 +213,11 @@ 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);
+ HValue* replacement =
+ NewLoadReplacement(load, state->OperandAt(index));
load->DeleteAndReplaceWith(replacement);
if (FLAG_trace_escape_analysis) {
- PrintF("Replacing load #%d with #%d (%s)\n", instr->id(),
+ PrintF("Replacing load #%d with #%d (%s)\n", load->id(),
replacement->id(), replacement->Mnemonic());
}
break;
« no previous file with comments | « src/hydrogen-escape-analysis.h ('k') | test/mjsunit/regress/regress-escape-preserve-smi-representation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698