Reviewers: Kevin Millikin,
Description:
Mark map-transition stores as map-changing instructions.
This prevents code motion from hoisting map-checks across such stores
which may result in unnecessary deoptimizations.
In the following example program we would move a map-check from the inner
loop
out before the outer loop which is not desirable:
function f() {
var o = {};
var j = 0;
o.a = 1;
do {
o.b = 6; // Map transition
for (var i=0; i<10; i++) {
o.a = o.b + i;
}
} while(++j < 1) {}
}
for (var i = 0; i < 1000000; i++) f();
Please review this at http://codereview.chromium.org/5991001/
SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/
Affected files:
M src/hydrogen-instructions.h
M src/hydrogen-instructions.cc
M src/hydrogen.cc
Index: src/hydrogen-instructions.cc
===================================================================
--- src/hydrogen-instructions.cc (revision 6055)
+++ src/hydrogen-instructions.cc (working copy)
@@ -579,6 +579,13 @@
}
+void HCompareMapAndBranch::PrintDataTo(StringStream* stream) const {
+ stream->Add("on ");
+ value()->PrintNameTo(stream);
+ stream->Add(" (%p)", *map());
+}
+
+
void HGoto::PrintDataTo(StringStream* stream) const {
stream->Add("B%d", FirstSuccessor()->block_id());
}
Index: src/hydrogen-instructions.h
===================================================================
--- src/hydrogen-instructions.h (revision 6055)
+++ src/hydrogen-instructions.h (working copy)
@@ -905,6 +905,8 @@
virtual HBasicBlock* FirstSuccessor() const { return true_destination_; }
virtual HBasicBlock* SecondSuccessor() const { return
false_destination_; }
+ virtual void PrintDataTo(StringStream* stream) const;
+
Handle<Map> map() const { return map_; }
DECLARE_CONCRETE_INSTRUCTION(CompareMapAndBranch, "compare_map_and_branch")
Index: src/hydrogen.cc
===================================================================
--- src/hydrogen.cc (revision 6055)
+++ src/hydrogen.cc (working copy)
@@ -3165,6 +3165,9 @@
if (lookup->type() == MAP_TRANSITION) {
Handle<Map> transition(lookup->GetTransitionMapFromMap(*type));
instr->set_transition(transition);
+ // TODO(fschneider): Record the new map type of the object in the IR to
+ // enable elimination of redundant checks after the transition store.
+ instr->SetFlag(HValue::kChangesMaps);
}
return instr;
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev