Revert "Refactor transitioning stores."
authorbmeurer@chromium.org <bmeurer@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 20 May 2014 13:03:25 +0000 (13:03 +0000)
committerbmeurer@chromium.org <bmeurer@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 20 May 2014 13:03:25 +0000 (13:03 +0000)
This reverts commit r21383 for breaking the Mozilla tests.

TBR=hpayer@chromium.org

Review URL: https://codereview.chromium.org/292993003

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21386 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

21 files changed:
src/arm/lithium-arm.cc
src/arm/lithium-arm.h
src/arm/lithium-codegen-arm.cc
src/arm64/lithium-arm64.cc
src/arm64/lithium-codegen-arm64.cc
src/hydrogen-check-elimination.cc
src/hydrogen-escape-analysis.cc
src/hydrogen-instructions.cc
src/hydrogen-instructions.h
src/hydrogen-load-elimination.cc
src/hydrogen-store-elimination.cc
src/hydrogen.cc
src/ia32/lithium-codegen-ia32.cc
src/ia32/lithium-ia32.cc
src/ia32/lithium-ia32.h
src/lithium-codegen.cc
src/lithium-codegen.h
src/lithium.cc
src/lithium.h
src/x64/lithium-codegen-x64.cc
src/x64/lithium-x64.cc

index 714c12a3fb2e3bd5956282663f49a994dd21624e..7a4de9f4ccad29a23d8605c4738d86492276bb96 100644 (file)
@@ -2279,6 +2279,8 @@ LInstruction* LChunkBuilder::DoTrapAllocationMemento(
 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
   bool is_in_object = instr->access().IsInobject();
   bool needs_write_barrier = instr->NeedsWriteBarrier();
+  bool needs_write_barrier_for_map = instr->has_transition() &&
+      instr->NeedsWriteBarrierForMap();
 
   LOperand* obj;
   if (needs_write_barrier) {
@@ -2286,7 +2288,9 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
         ? UseRegister(instr->object())
         : UseTempRegister(instr->object());
   } else {
-    obj = UseRegisterAtStart(instr->object());
+    obj = needs_write_barrier_for_map
+        ? UseRegister(instr->object())
+        : UseRegisterAtStart(instr->object());
   }
 
   LOperand* val;
@@ -2298,7 +2302,10 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
     val = UseRegister(instr->value());
   }
 
-  LInstruction* result = new(zone()) LStoreNamedField(obj, val);
+  // We need a temporary register for write barrier of the map field.
+  LOperand* temp = needs_write_barrier_for_map ? TempRegister() : NULL;
+
+  LInstruction* result = new(zone()) LStoreNamedField(obj, val, temp);
   if (!instr->access().IsExternalMemory() &&
       instr->field_representation().IsHeapObject() &&
       !instr->value()->type().IsHeapObject()) {
index d3f1efe2b973f8a5f931aae7b72c8e64e524a177..b333095c7933cffc6292ef63b24b2d2c1301e80c 100644 (file)
@@ -2145,15 +2145,17 @@ class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
 };
 
 
-class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 0> {
+class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
  public:
-  LStoreNamedField(LOperand* object, LOperand* value) {
+  LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
     inputs_[0] = object;
     inputs_[1] = value;
+    temps_[0] = temp;
   }
 
   LOperand* object() { return inputs_[0]; }
   LOperand* value() { return inputs_[1]; }
+  LOperand* temp() { return temps_[0]; }
 
   DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
   DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
index f510c85c2c39bd52dad1d0d7f2d558c3ab9b6337..623a9dca452d8195ab26de7d5060f1a905978282 100644 (file)
@@ -4097,12 +4097,32 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
     }
   } else if (representation.IsDouble()) {
     ASSERT(access.IsInobject());
+    ASSERT(!instr->hydrogen()->has_transition());
     ASSERT(!instr->hydrogen()->NeedsWriteBarrier());
     DwVfpRegister value = ToDoubleRegister(instr->value());
     __ vstr(value, FieldMemOperand(object, offset));
     return;
   }
 
+  if (instr->hydrogen()->has_transition()) {
+    Handle<Map> transition = instr->hydrogen()->transition_map();
+    AddDeprecationDependency(transition);
+    __ mov(scratch, Operand(transition));
+    __ str(scratch, FieldMemOperand(object, HeapObject::kMapOffset));
+    if (instr->hydrogen()->NeedsWriteBarrierForMap()) {
+      Register temp = ToRegister(instr->temp());
+      // Update the write barrier for the map field.
+      __ RecordWriteField(object,
+                          HeapObject::kMapOffset,
+                          scratch,
+                          temp,
+                          GetLinkRegisterState(),
+                          kSaveFPRegs,
+                          OMIT_REMEMBERED_SET,
+                          OMIT_SMI_CHECK);
+    }
+  }
+
   // Do the store.
   Register value = ToRegister(instr->value());
   if (access.IsInobject()) {
index 30076679e2cd3cbeb7af6236ac0d915fdbdea52e..d18808a587b1cd2a50dc9a58120786de46a978ea 100644 (file)
@@ -2371,6 +2371,10 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
     value = UseRegisterAndClobber(instr->value());
     temp0 = TempRegister();
     temp1 = TempRegister();
+  } else if (instr->NeedsWriteBarrierForMap()) {
+    value = UseRegister(instr->value());
+    temp0 = TempRegister();
+    temp1 = TempRegister();
   } else {
     value = UseRegister(instr->value());
     temp0 = TempRegister();
index 462c20ffd03a9bedb6b91f1409cace17a90ce570..dab60e572ed9e5c541128c51a57bbb318efd6b6a 100644 (file)
@@ -5302,12 +5302,14 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
   int offset = access.offset();
 
   if (access.IsExternalMemory()) {
+    ASSERT(!instr->hydrogen()->has_transition());
     ASSERT(!instr->hydrogen()->NeedsWriteBarrier());
     Register value = ToRegister(instr->value());
     __ Store(value, MemOperand(object, offset), representation);
     return;
   } else if (representation.IsDouble()) {
     ASSERT(access.IsInobject());
+    ASSERT(!instr->hydrogen()->has_transition());
     ASSERT(!instr->hydrogen()->NeedsWriteBarrier());
     FPRegister value = ToDoubleRegister(instr->value());
     __ Str(value, FieldMemOperand(object, offset));
@@ -5330,6 +5332,26 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
     check_needed = OMIT_SMI_CHECK;
   }
 
+  if (instr->hydrogen()->has_transition()) {
+    Handle<Map> transition = instr->hydrogen()->transition_map();
+    AddDeprecationDependency(transition);
+    // Store the new map value.
+    Register new_map_value = ToRegister(instr->temp0());
+    __ Mov(new_map_value, Operand(transition));
+    __ Str(new_map_value, FieldMemOperand(object, HeapObject::kMapOffset));
+    if (instr->hydrogen()->NeedsWriteBarrierForMap()) {
+      // Update the write barrier for the map field.
+      __ RecordWriteField(object,
+                          HeapObject::kMapOffset,
+                          new_map_value,
+                          ToRegister(instr->temp1()),
+                          GetLinkRegisterState(),
+                          kSaveFPRegs,
+                          OMIT_REMEMBERED_SET,
+                          OMIT_SMI_CHECK);
+    }
+  }
+
   // Do the store.
   Register destination;
   if (access.IsInobject()) {
index c4e24e246edf6fafa2d18d4d673232931e1622cd..f3c5cbe151e3e7e1615834bf3834927158e03f78 100644 (file)
@@ -451,7 +451,15 @@ class HCheckTable : public ZoneObject {
 
   void ReduceStoreNamedField(HStoreNamedField* instr) {
     HValue* object = instr->object()->ActualValue();
-    if (instr->access().IsMap()) {
+    if (instr->has_transition()) {
+      // This store transitions the object to a new map.
+      Kill(object);
+      HConstant* c_transition = HConstant::cast(instr->transition());
+      HCheckTableEntry::State state = c_transition->HasStableMapValue()
+          ? HCheckTableEntry::CHECKED_STABLE
+          : HCheckTableEntry::CHECKED;
+      Insert(object, NULL, c_transition->MapValue(), state);
+    } else if (instr->access().IsMap()) {
       // This is a store directly to the map field of the object.
       Kill(object);
       if (!instr->value()->IsConstant()) return;
@@ -706,7 +714,7 @@ class HCheckMapsEffects : public ZoneObject {
     switch (instr->opcode()) {
       case HValue::kStoreNamedField: {
         HStoreNamedField* store = HStoreNamedField::cast(instr);
-        if (store->access().IsMap()) {
+        if (store->access().IsMap() || store->has_transition()) {
           objects_.Add(store->object(), zone);
         }
         break;
index 9f4ee6cbec0d59b938e2ac0d8ecce5346bd502b9..4eb2a13726a4dd5dd0bd84bfdfbaedfc1ba12a6d 100644 (file)
@@ -206,12 +206,16 @@ void HEscapeAnalysisPhase::AnalyzeDataFlow(HInstruction* allocate) {
           ASSERT(store->access().IsInobject());
           state = NewStateCopy(store->previous(), state);
           state->SetOperandAt(index, store->value());
+          if (store->has_transition()) {
+            state->SetOperandAt(0, store->transition());
+          }
           if (store->HasObservableSideEffects()) {
             state->ReuseSideEffectsFromStore(store);
           }
           store->DeleteAndReplaceWith(store->ActualValue());
           if (FLAG_trace_escape_analysis) {
-            PrintF("Replacing store #%d\n", instr->id());
+            PrintF("Replacing store #%d%s\n", instr->id(),
+                   store->has_transition() ? " (with transition)" : "");
           }
           break;
         }
index c44f01a1741302adc46f9b4b840333e9c95b4574..bfdc9499deb2290f87ec1e24ae31e399ed75b432 100644 (file)
@@ -3589,6 +3589,9 @@ void HStoreNamedField::PrintDataTo(StringStream* stream) {
   if (NeedsWriteBarrier()) {
     stream->Add(" (write-barrier)");
   }
+  if (has_transition()) {
+    stream->Add(" (transition map %p)", *transition_map());
+  }
 }
 
 
index 37f735a1a883c31a7f6ab99844f521b8833721c4..918229b1ae11f8e9141944139fdac15f0f7c813d 100644 (file)
@@ -6656,7 +6656,7 @@ enum StoreFieldOrKeyedMode {
 };
 
 
-class HStoreNamedField V8_FINAL : public HTemplateInstruction<2> {
+class HStoreNamedField V8_FINAL : public HTemplateInstruction<3> {
  public:
   DECLARE_INSTRUCTION_FACTORY_P3(HStoreNamedField, HValue*,
                                  HObjectAccess, HValue*);
@@ -6706,12 +6706,30 @@ class HStoreNamedField V8_FINAL : public HTemplateInstruction<2> {
 
   HValue* object() const { return OperandAt(0); }
   HValue* value() const { return OperandAt(1); }
+  HValue* transition() const { return OperandAt(2); }
 
   HObjectAccess access() const { return access_; }
   HValue* new_space_dominator() const { return new_space_dominator_; }
+  bool has_transition() const { return has_transition_; }
   StoreFieldOrKeyedMode store_mode() const { return store_mode_; }
 
+  Handle<Map> transition_map() const {
+    if (has_transition()) {
+      return Handle<Map>::cast(
+          HConstant::cast(transition())->handle(Isolate::Current()));
+    } else {
+      return Handle<Map>();
+    }
+  }
+
+  void SetTransition(HConstant* transition) {
+    ASSERT(!has_transition());  // Only set once.
+    SetOperandAt(2, transition);
+    has_transition_ = true;
+  }
+
   bool NeedsWriteBarrier() {
+    ASSERT(!field_representation().IsDouble() || !has_transition());
     if (field_representation().IsDouble()) return false;
     if (field_representation().IsSmi()) return false;
     if (field_representation().IsInteger32()) return false;
@@ -6721,6 +6739,11 @@ class HStoreNamedField V8_FINAL : public HTemplateInstruction<2> {
                                         new_space_dominator());
   }
 
+  bool NeedsWriteBarrierForMap() {
+    return ReceiverObjectNeedsWriteBarrier(object(), transition(),
+                                           new_space_dominator());
+  }
+
   Representation field_representation() const {
     return access_.representation();
   }
@@ -6736,6 +6759,7 @@ class HStoreNamedField V8_FINAL : public HTemplateInstruction<2> {
                    StoreFieldOrKeyedMode store_mode = INITIALIZING_STORE)
       : access_(access),
         new_space_dominator_(NULL),
+        has_transition_(false),
         store_mode_(store_mode) {
     // Stores to a non existing in-object property are allowed only to the
     // newly allocated objects (via HAllocate or HInnerAllocatedObject).
@@ -6743,11 +6767,13 @@ class HStoreNamedField V8_FINAL : public HTemplateInstruction<2> {
            obj->IsAllocate() || obj->IsInnerAllocatedObject());
     SetOperandAt(0, obj);
     SetOperandAt(1, val);
+    SetOperandAt(2, obj);
     access.SetGVNFlags(this, STORE);
   }
 
   HObjectAccess access_;
   HValue* new_space_dominator_;
+  bool has_transition_ : 1;
   StoreFieldOrKeyedMode store_mode_ : 1;
 };
 
index 6967630b57cd4e25c8ddf27ae65e483845821996..1198d2b7ab59afeb6318745c0cf45fcf440138bf 100644 (file)
@@ -240,7 +240,12 @@ class HLoadEliminationTable : public ZoneObject {
     HValue* object = instr->object()->ActualValue();
     HValue* value = instr->value();
 
-    if (instr->store_mode() == STORE_TO_INITIALIZED_ENTRY) {
+    if (instr->has_transition()) {
+      // A transition introduces a new field and alters the map of the object.
+      // Since the field in the object is new, it cannot alias existing entries.
+      // TODO(titzer): introduce a constant for the new map and remember it.
+      KillFieldInternal(object, FieldOf(JSObject::kMapOffset), NULL);
+    } else {
       // Kill non-equivalent may-alias entries.
       KillFieldInternal(object, field, value);
     }
index f6f85da760045eb10dd7ac2638d76a1d877f55fd..cf5f3a15e69822491cb8e0ebda685fd576223f95 100644 (file)
@@ -58,11 +58,7 @@ void HStoreEliminationPhase::ProcessStore(HStoreNamedField* store) {
   while (i < unobserved_.length()) {
     HStoreNamedField* prev = unobserved_.at(i);
     if (aliasing_->MustAlias(object, prev->object()->ActualValue()) &&
-        store->access().Equals(prev->access()) &&
-        (!SmiValuesAre32Bits() ||
-         !store->field_representation().IsSmi() ||
-         store->store_mode() == STORE_TO_INITIALIZED_ENTRY ||
-         prev->store_mode() == INITIALIZING_STORE)) {
+        store->access().Equals(prev->access())) {
       // This store is guaranteed to overwrite the previous store.
       prev->DeleteAndReplaceWith(NULL);
       TRACE(("++ Unobserved store S%d overwritten by S%d\n",
@@ -73,8 +69,11 @@ void HStoreEliminationPhase::ProcessStore(HStoreNamedField* store) {
       i++;
     }
   }
-  TRACE(("-- Might remove store S%d\n", store->id()));
-  unobserved_.Add(store, zone());
+  // Only non-transitioning stores are removable.
+  if (!store->has_transition()) {
+    TRACE(("-- Might remove store S%d\n", store->id()));
+    unobserved_.Add(store, zone());
+  }
 }
 
 
index c7b8eea46cc9dd3d5587d1291effc250041ea368..b296b9372379bf8bcfc91809d7750d0d9207c03d 100644 (file)
@@ -5521,14 +5521,7 @@ HInstruction* HOptimizedGraphBuilder::BuildStoreNamedField(
   if (transition_to_field) {
     Handle<Map> transition(info->transition());
     ASSERT(!transition->is_deprecated());
-    if (transition->CanBeDeprecated()) {
-      Map::AddDependentCompilationInfo(
-          transition, DependentCode::kTransitionGroup, top_info());
-    }
-    Add<HStoreNamedField>(checked_object->ActualValue(),
-                          HObjectAccess::ForMap(),
-                          Add<HConstant>(transition),
-                          STORE_TO_INITIALIZED_ENTRY);
+    instr->SetTransition(Add<HConstant>(transition));
   }
   return instr;
 }
index b79fc33c7f0406e6295c11b88191366d30c8428a..906ee3e97b8efb5d53f5d487e27ea00cab968908 100644 (file)
@@ -4003,12 +4003,34 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
     }
   } else if (representation.IsDouble()) {
     ASSERT(access.IsInobject());
+    ASSERT(!instr->hydrogen()->has_transition());
     ASSERT(!instr->hydrogen()->NeedsWriteBarrier());
     XMMRegister value = ToDoubleRegister(instr->value());
     __ movsd(FieldOperand(object, offset), value);
     return;
   }
 
+  if (instr->hydrogen()->has_transition()) {
+    Handle<Map> transition = instr->hydrogen()->transition_map();
+    AddDeprecationDependency(transition);
+    if (!instr->hydrogen()->NeedsWriteBarrierForMap()) {
+      __ mov(FieldOperand(object, HeapObject::kMapOffset), transition);
+    } else {
+      Register temp = ToRegister(instr->temp());
+      Register temp_map = ToRegister(instr->temp_map());
+      __ mov(temp_map, transition);
+      __ mov(FieldOperand(object, HeapObject::kMapOffset), temp_map);
+      // Update the write barrier for the map field.
+      __ RecordWriteField(object,
+                          HeapObject::kMapOffset,
+                          temp_map,
+                          temp,
+                          kSaveFPRegs,
+                          OMIT_REMEMBERED_SET,
+                          OMIT_SMI_CHECK);
+    }
+  }
+
   // Do the store.
   Register write_register = object;
   if (!access.IsInobject()) {
index 2980bd4a90ee31d5972d286757a20a9dc581c717..067863d0b0f4d4a1df4a348f11943f5d04c4e3b6 100644 (file)
@@ -2340,6 +2340,8 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
   bool is_external_location = instr->access().IsExternalMemory() &&
       instr->access().offset() == 0;
   bool needs_write_barrier = instr->NeedsWriteBarrier();
+  bool needs_write_barrier_for_map = instr->has_transition() &&
+      instr->NeedsWriteBarrierForMap();
 
   LOperand* obj;
   if (needs_write_barrier) {
@@ -2349,9 +2351,12 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
   } else if (is_external_location) {
     ASSERT(!is_in_object);
     ASSERT(!needs_write_barrier);
+    ASSERT(!needs_write_barrier_for_map);
     obj = UseRegisterOrConstant(instr->object());
   } else {
-    obj = UseRegisterAtStart(instr->object());
+    obj = needs_write_barrier_for_map
+        ? UseRegister(instr->object())
+        : UseRegisterAtStart(instr->object());
   }
 
   bool can_be_constant = instr->value()->IsConstant() &&
@@ -2378,11 +2383,14 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
 
   // We only need a scratch register if we have a write barrier or we
   // have a store into the properties array (not in-object-property).
-  LOperand* temp = (!is_in_object || needs_write_barrier)
-      ? TempRegister() : NULL;
+  LOperand* temp = (!is_in_object || needs_write_barrier ||
+                    needs_write_barrier_for_map) ? TempRegister() : NULL;
+
+  // We need a temporary register for write barrier of the map field.
+  LOperand* temp_map = needs_write_barrier_for_map ? TempRegister() : NULL;
 
   LInstruction* result =
-      new(zone()) LStoreNamedField(obj, val, temp);
+      new(zone()) LStoreNamedField(obj, val, temp, temp_map);
   if (!instr->access().IsExternalMemory() &&
       instr->field_representation().IsHeapObject() &&
       (val->IsConstantOperand()
index 8b0fb8157a2537a02ef91f79df2ca27309faa46a..ae8013891f087e07886722b87f2370167177b9f1 100644 (file)
@@ -2151,19 +2151,22 @@ class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
 };
 
 
-class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
+class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 2> {
  public:
   LStoreNamedField(LOperand* obj,
                    LOperand* val,
-                   LOperand* temp) {
+                   LOperand* temp,
+                   LOperand* temp_map) {
     inputs_[0] = obj;
     inputs_[1] = val;
     temps_[0] = temp;
+    temps_[1] = temp_map;
   }
 
   LOperand* object() { return inputs_[0]; }
   LOperand* value() { return inputs_[1]; }
   LOperand* temp() { return temps_[0]; }
+  LOperand* temp_map() { return temps_[1]; }
 
   DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
   DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
index 0a7690cf4c72fc8a8192cc52b43cf69fb9e6e31d..0d841b7e80a2420c6b906767abcc72d9fa637b40 100644 (file)
@@ -216,6 +216,12 @@ void LCodeGenBase::Abort(BailoutReason reason) {
 }
 
 
+void LCodeGenBase::AddDeprecationDependency(Handle<Map> map) {
+  if (map->is_deprecated()) return Abort(kMapBecameDeprecated);
+  chunk_->AddDeprecationDependency(map);
+}
+
+
 void LCodeGenBase::AddStabilityDependency(Handle<Map> map) {
   if (!map->is_stable()) return Abort(kMapBecameUnstable);
   chunk_->AddStabilityDependency(map);
index 9fb886ff5c7a28088de84aeec7528483f94cf5aa..28a5ab16e0ca326593cb3d6241eb2cb16605499e 100644 (file)
@@ -76,6 +76,7 @@ class LCodeGenBase BASE_EMBEDDED {
   void Abort(BailoutReason reason);
 
   // Methods for code dependencies.
+  void AddDeprecationDependency(Handle<Map> map);
   void AddStabilityDependency(Handle<Map> map);
 };
 
index 74da8a3074c8a784eae5c9b80ed54bd5bce7a451..c6d64135c32d8d513753d2980ecbce1fccb83cb1 100644 (file)
@@ -238,6 +238,7 @@ LChunk::LChunk(CompilationInfo* info, HGraph* graph)
       instructions_(32, graph->zone()),
       pointer_maps_(8, graph->zone()),
       inlined_closures_(1, graph->zone()),
+      deprecation_dependencies_(MapLess(), MapAllocator(graph->zone())),
       stability_dependencies_(MapLess(), MapAllocator(graph->zone())) {
 }
 
@@ -378,6 +379,14 @@ Representation LChunk::LookupLiteralRepresentation(
 
 
 void LChunk::CommitDependencies(Handle<Code> code) const {
+  for (MapSet::const_iterator it = deprecation_dependencies_.begin(),
+       iend = deprecation_dependencies_.end(); it != iend; ++it) {
+    Handle<Map> map = *it;
+    ASSERT(!map->is_deprecated());
+    ASSERT(map->CanBeDeprecated());
+    Map::AddDependentCode(map, DependentCode::kTransitionGroup, code);
+  }
+
   for (MapSet::const_iterator it = stability_dependencies_.begin(),
        iend = stability_dependencies_.end(); it != iend; ++it) {
     Handle<Map> map = *it;
index b3d11789d55a82fc30c9bd512fa130be93c71185..650bae69235a3205aa1edeebd5f8c484bf3c3713 100644 (file)
@@ -650,6 +650,13 @@ class LChunk : public ZoneObject {
     inlined_closures_.Add(closure, zone());
   }
 
+  void AddDeprecationDependency(Handle<Map> map) {
+    ASSERT(!map->is_deprecated());
+    if (!map->CanBeDeprecated()) return;
+    ASSERT(!info_->IsStub());
+    deprecation_dependencies_.insert(map);
+  }
+
   void AddStabilityDependency(Handle<Map> map) {
     ASSERT(map->is_stable());
     if (!map->CanTransition()) return;
@@ -684,6 +691,7 @@ class LChunk : public ZoneObject {
   ZoneList<LInstruction*> instructions_;
   ZoneList<LPointerMap*> pointer_maps_;
   ZoneList<Handle<JSFunction> > inlined_closures_;
+  MapSet deprecation_dependencies_;
   MapSet stability_dependencies_;
 };
 
index 3ef4599ef0b6a3c57860c8868d9c354a8d790531..1d1da3d38371e65e9e9c92a3ca741598cf9c7fd4 100644 (file)
@@ -4021,12 +4021,33 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
     }
   } else if (representation.IsDouble()) {
     ASSERT(access.IsInobject());
+    ASSERT(!hinstr->has_transition());
     ASSERT(!hinstr->NeedsWriteBarrier());
     XMMRegister value = ToDoubleRegister(instr->value());
     __ movsd(FieldOperand(object, offset), value);
     return;
   }
 
+  if (hinstr->has_transition()) {
+    Handle<Map> transition = hinstr->transition_map();
+    AddDeprecationDependency(transition);
+    if (!hinstr->NeedsWriteBarrierForMap()) {
+      __ Move(FieldOperand(object, HeapObject::kMapOffset), transition);
+    } else {
+      Register temp = ToRegister(instr->temp());
+      __ Move(kScratchRegister, transition);
+      __ movp(FieldOperand(object, HeapObject::kMapOffset), kScratchRegister);
+      // Update the write barrier for the map field.
+      __ RecordWriteField(object,
+                          HeapObject::kMapOffset,
+                          kScratchRegister,
+                          temp,
+                          kSaveFPRegs,
+                          OMIT_REMEMBERED_SET,
+                          OMIT_SMI_CHECK);
+    }
+  }
+
   // Do the store.
   Register write_register = object;
   if (!access.IsInobject()) {
index d10b4364a1e46c901a2f8c8b94ea816f4854f47e..cbade8a7d95fac4b2309b7e1fd648a3f17ba1454 100644 (file)
@@ -2276,6 +2276,8 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
   bool is_external_location = instr->access().IsExternalMemory() &&
       instr->access().offset() == 0;
   bool needs_write_barrier = instr->NeedsWriteBarrier();
+  bool needs_write_barrier_for_map = instr->has_transition() &&
+      instr->NeedsWriteBarrierForMap();
 
   LOperand* obj;
   if (needs_write_barrier) {
@@ -2285,9 +2287,12 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
   } else if (is_external_location) {
     ASSERT(!is_in_object);
     ASSERT(!needs_write_barrier);
+    ASSERT(!needs_write_barrier_for_map);
     obj = UseRegisterOrConstant(instr->object());
   } else {
-    obj = UseRegisterAtStart(instr->object());
+    obj = needs_write_barrier_for_map
+        ? UseRegister(instr->object())
+        : UseRegisterAtStart(instr->object());
   }
 
   bool can_be_constant = instr->value()->IsConstant() &&
@@ -2311,8 +2316,8 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
 
   // We only need a scratch register if we have a write barrier or we
   // have a store into the properties array (not in-object-property).
-  LOperand* temp = (!is_in_object || needs_write_barrier)
-      ? TempRegister() : NULL;
+  LOperand* temp = (!is_in_object || needs_write_barrier ||
+      needs_write_barrier_for_map) ? TempRegister() : NULL;
 
   LInstruction* result = new(zone()) LStoreNamedField(obj, val, temp);
   if (!instr->access().IsExternalMemory() &&