Revision: 6071
Author: [email protected]
Date: Fri Dec 17 05:44:19 2010
Log: 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();


Review URL: http://codereview.chromium.org/5991001
http://code.google.com/p/v8/source/detail?r=6071

Modified:
 /branches/bleeding_edge/src/hydrogen-instructions.cc
 /branches/bleeding_edge/src/hydrogen-instructions.h
 /branches/bleeding_edge/src/hydrogen.cc

=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Thu Dec 16 10:01:36 2010 +++ /branches/bleeding_edge/src/hydrogen-instructions.cc Fri Dec 17 05:44:19 2010
@@ -577,6 +577,13 @@
   value()->PrintNameTo(stream);
   stream->Add(" (B%d, B%d)", first_id, second_id);
 }
+
+
+void HCompareMapAndBranch::PrintDataTo(StringStream* stream) const {
+  stream->Add("on ");
+  value()->PrintNameTo(stream);
+  stream->Add(" (%p)", *map());
+}


 void HGoto::PrintDataTo(StringStream* stream) const {
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Thu Dec 16 10:01:36 2010 +++ /branches/bleeding_edge/src/hydrogen-instructions.h Fri Dec 17 05:44:19 2010
@@ -904,6 +904,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_; }

=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Thu Dec 16 14:30:53 2010
+++ /branches/bleeding_edge/src/hydrogen.cc     Fri Dec 17 05:44:19 2010
@@ -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

Reply via email to