Stores to external references don't need write barriers.
authorbmeurer@chromium.org <bmeurer@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 31 Jul 2013 13:45:51 +0000 (13:45 +0000)
committerbmeurer@chromium.org <bmeurer@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 31 Jul 2013 13:45:51 +0000 (13:45 +0000)
This also applies to stores with an external field representation.

Also cleans up the CreateAllocationSiteStub.

R=mstarzinger@chromium.org, mvstanton@chromium.org

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

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

src/code-stubs-hydrogen.cc
src/hydrogen-instructions.h
src/ia32/lithium-codegen-ia32.cc
src/x64/lithium-codegen-x64.cc

index 151f2de7374efb966218cb5251de0a43d469188c..b6a8a668bcf57cabc250e2a0407710b9f25d6394 100644 (file)
@@ -459,11 +459,9 @@ Handle<Code> FastCloneShallowObjectStub::GenerateCode() {
 
 template <>
 HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() {
-  Zone* zone = this->zone();
-
-  HValue* size = AddInstruction(new(zone) HConstant(AllocationSite::kSize));
-  HInstruction* object = AddInstruction(new(zone)
-      HAllocate(context(), size, HType::JSObject(), true));
+  HValue* size = Add<HConstant>(AllocationSite::kSize);
+  HInstruction* object = Add<HAllocate>(
+      context(), size, HType::JSObject(), true);
 
   // Store the map
   Handle<Map> allocation_site_map(isolate()->heap()->allocation_site_map(),
@@ -471,8 +469,7 @@ HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() {
   AddStoreMapConstant(object, allocation_site_map);
 
   // Store the payload (smi elements kind)
-  HValue* initial_elements_kind = AddInstruction(new(zone) HConstant(
-      GetInitialFastElementsKind()));
+  HValue* initial_elements_kind = Add<HConstant>(GetInitialFastElementsKind());
   Add<HStoreNamedField>(object,
                         HObjectAccess::ForAllocationSiteTransitionInfo(),
                         initial_elements_kind);
index 6e7435af0627fc68d384fe81f37e80d2b6262a78..1bd27cb68561205f3ea927756bc0695ec652439c 100644 (file)
@@ -5374,6 +5374,11 @@ inline bool ReceiverObjectNeedsWriteBarrier(HValue* object,
   if (object->IsConstant() && HConstant::cast(object)->IsCell()) {
     return false;
   }
+  if (object->IsConstant() &&
+      HConstant::cast(object)->HasExternalReferenceValue()) {
+    // Stores to external references require no write barriers
+    return false;
+  }
   if (object != new_space_dominator) return true;
   if (object->IsAllocate()) {
     return !HAllocate::cast(object)->IsNewSpaceAllocation();
@@ -6155,6 +6160,7 @@ class HStoreNamedField: public HTemplateInstruction<2> {
     if (field_representation().IsDouble()) return false;
     if (field_representation().IsSmi()) return false;
     if (field_representation().IsInteger32()) return false;
+    if (field_representation().IsExternal()) return false;
     return StoringValueNeedsWriteBarrier(value()) &&
         ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator());
   }
index 0d20dea90ae793223117aaea6e680ba38ce22b29..013a921c5f9f75662fe78c8ba7209dab5160bb66 100644 (file)
@@ -4342,6 +4342,7 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
   int offset = access.offset();
 
   if (access.IsExternalMemory()) {
+    ASSERT(!instr->hydrogen()->NeedsWriteBarrier());
     MemOperand operand = instr->object()->IsConstantOperand()
         ? MemOperand::StaticVariable(
             ToExternalReference(LConstantOperand::cast(instr->object())))
index 58dd5157a9a13ed9a5ba88cfd87909e0ef2b3fd6..a8a691ed5daf7b25279112f7aaa25a259d9b841f 100644 (file)
@@ -3942,6 +3942,7 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
   int offset = access.offset();
 
   if (access.IsExternalMemory()) {
+    ASSERT(!instr->hydrogen()->NeedsWriteBarrier());
     Register value = ToRegister(instr->value());
     if (instr->object()->IsConstantOperand()) {
       ASSERT(value.is(rax));