Revision: 21668
Author:   [email protected]
Date:     Wed Jun  4 09:27:16 2014 UTC
Log:      X87: Improve write barriers in optimized code.

Port r21630 (a21ff10)

Original commit message:
Use a cheaper RecordWriteForMap() to update the
write barrier for maps. And skip the value check
in RecordWriteField() when we statically know that
the value is in new space (and therefore has "pointers
to here are interesting" flag set).

BUG=
[email protected]

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

Patch from Chunyang Dai <[email protected]>.
http://code.google.com/p/v8/source/detail?r=21668

Modified:
 /branches/bleeding_edge/src/x87/lithium-codegen-x87.cc
 /branches/bleeding_edge/src/x87/macro-assembler-x87.cc
 /branches/bleeding_edge/src/x87/macro-assembler-x87.h

=======================================
--- /branches/bleeding_edge/src/x87/lithium-codegen-x87.cc Tue Jun 3 08:12:43 2014 UTC +++ /branches/bleeding_edge/src/x87/lithium-codegen-x87.cc Wed Jun 4 09:27:16 2014 UTC
@@ -3904,20 +3904,14 @@
   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 {
+    __ mov(FieldOperand(object, HeapObject::kMapOffset), transition);
+    if (instr->hydrogen()->NeedsWriteBarrierForMap()) {
       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,
-                          OMIT_REMEMBERED_SET,
-                          OMIT_SMI_CHECK);
+      __ RecordWriteForMap(object, transition, temp_map, temp);
     }
   }

@@ -3957,7 +3951,8 @@
                         value,
                         temp,
                         EMIT_REMEMBERED_SET,
-                        instr->hydrogen()->SmiCheckForWriteBarrier());
+                        instr->hydrogen()->SmiCheckForWriteBarrier(),
+                        instr->hydrogen()->PointersToHereCheckForValue());
   }
 }

@@ -4155,7 +4150,8 @@
                    key,
                    value,
                    EMIT_REMEMBERED_SET,
-                   check_needed);
+                   check_needed,
+                   instr->hydrogen()->PointersToHereCheckForValue());
   }
 }

=======================================
--- /branches/bleeding_edge/src/x87/macro-assembler-x87.cc Tue Jun 3 08:12:43 2014 UTC +++ /branches/bleeding_edge/src/x87/macro-assembler-x87.cc Wed Jun 4 09:27:16 2014 UTC
@@ -315,11 +315,13 @@
 }


-void MacroAssembler::RecordWriteArray(Register object,
-                                      Register value,
-                                      Register index,
- RememberedSetAction remembered_set_action,
-                                      SmiCheck smi_check) {
+void MacroAssembler::RecordWriteArray(
+    Register object,
+    Register value,
+    Register index,
+    RememberedSetAction remembered_set_action,
+    SmiCheck smi_check,
+    PointersToHereCheck pointers_to_here_check_for_value) {
   // First, check if a write barrier is even needed. The tests below
   // catch stores of Smis.
   Label done;
@@ -338,8 +340,8 @@
   lea(dst, Operand(object, index, times_half_pointer_size,
                    FixedArray::kHeaderSize - kHeapObjectTag));

-  RecordWrite(
-      object, dst, value, remembered_set_action, OMIT_SMI_CHECK);
+  RecordWrite(object, dst, value, remembered_set_action, OMIT_SMI_CHECK,
+              pointers_to_here_check_for_value);

   bind(&done);

@@ -358,7 +360,8 @@
     Register value,
     Register dst,
     RememberedSetAction remembered_set_action,
-    SmiCheck smi_check) {
+    SmiCheck smi_check,
+    PointersToHereCheck pointers_to_here_check_for_value) {
   // First, check if a write barrier is even needed. The tests below
   // catch stores of Smis.
   Label done;
@@ -381,8 +384,8 @@
     bind(&ok);
   }

-  RecordWrite(
-      object, dst, value, remembered_set_action, OMIT_SMI_CHECK);
+  RecordWrite(object, dst, value, remembered_set_action, OMIT_SMI_CHECK,
+              pointers_to_here_check_for_value);

   bind(&done);

@@ -421,6 +424,9 @@
   if (!FLAG_incremental_marking) {
     return;
   }
+
+  // Compute the address.
+  lea(address, FieldOperand(object, HeapObject::kMapOffset));

   // Count number of write barriers in generated code.
   isolate()->counters()->write_barriers_static()->Increment();
@@ -437,12 +443,6 @@
                       &done,
                       Label::kNear);

- // Delay the initialization of |address| and |value| for the stub until it's - // known that the will be needed. Up until this point their values are not - // needed since they are embedded in the operands of instructions that need
-  // them.
-  lea(address, FieldOperand(object, HeapObject::kMapOffset));
-  mov(value, Immediate(map));
RecordWriteStub stub(isolate(), object, value, address, OMIT_REMEMBERED_SET);
   CallStub(&stub);

@@ -458,11 +458,13 @@
 }


-void MacroAssembler::RecordWrite(Register object,
-                                 Register address,
-                                 Register value,
-                                 RememberedSetAction remembered_set_action,
-                                 SmiCheck smi_check) {
+void MacroAssembler::RecordWrite(
+    Register object,
+    Register address,
+    Register value,
+    RememberedSetAction remembered_set_action,
+    SmiCheck smi_check,
+    PointersToHereCheck pointers_to_here_check_for_value) {
   ASSERT(!object.is(value));
   ASSERT(!object.is(address));
   ASSERT(!value.is(address));
@@ -494,12 +496,14 @@
     JumpIfSmi(value, &done, Label::kNear);
   }

-  CheckPageFlag(value,
-                value,  // Used as scratch.
-                MemoryChunk::kPointersToHereAreInterestingMask,
-                zero,
-                &done,
-                Label::kNear);
+ if (pointers_to_here_check_for_value != kPointersToHereAreAlwaysInteresting) {
+    CheckPageFlag(value,
+                  value,  // Used as scratch.
+                  MemoryChunk::kPointersToHereAreInterestingMask,
+                  zero,
+                  &done,
+                  Label::kNear);
+  }
   CheckPageFlag(object,
                 value,  // Used as scratch.
                 MemoryChunk::kPointersFromHereAreInterestingMask,
=======================================
--- /branches/bleeding_edge/src/x87/macro-assembler-x87.h Tue Jun 3 08:12:43 2014 UTC +++ /branches/bleeding_edge/src/x87/macro-assembler-x87.h Wed Jun 4 09:27:16 2014 UTC
@@ -18,6 +18,10 @@

 enum RememberedSetAction { EMIT_REMEMBERED_SET, OMIT_REMEMBERED_SET };
 enum SmiCheck { INLINE_SMI_CHECK, OMIT_SMI_CHECK };
+enum PointersToHereCheck {
+  kPointersToHereMaybeInteresting,
+  kPointersToHereAreAlwaysInteresting
+};


 enum RegisterValueType {
@@ -138,7 +142,9 @@
       Register value,
       Register scratch,
       RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET,
-      SmiCheck smi_check = INLINE_SMI_CHECK);
+      SmiCheck smi_check = INLINE_SMI_CHECK,
+      PointersToHereCheck pointers_to_here_check_for_value =
+          kPointersToHereMaybeInteresting);

   // As above, but the offset has the tag presubtracted.  For use with
   // Operand(reg, off).
@@ -148,13 +154,16 @@
       Register value,
       Register scratch,
       RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET,
-      SmiCheck smi_check = INLINE_SMI_CHECK) {
+      SmiCheck smi_check = INLINE_SMI_CHECK,
+      PointersToHereCheck pointers_to_here_check_for_value =
+          kPointersToHereMaybeInteresting) {
     RecordWriteField(context,
                      offset + kHeapObjectTag,
                      value,
                      scratch,
                      remembered_set_action,
-                     smi_check);
+                     smi_check,
+                     pointers_to_here_check_for_value);
   }

// Notify the garbage collector that we wrote a pointer into a fixed array.
@@ -168,7 +177,9 @@
       Register value,
       Register index,
       RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET,
-      SmiCheck smi_check = INLINE_SMI_CHECK);
+      SmiCheck smi_check = INLINE_SMI_CHECK,
+      PointersToHereCheck pointers_to_here_check_for_value =
+          kPointersToHereMaybeInteresting);

   // For page containing |object| mark region covering |address|
   // dirty. |object| is the object being stored into, |value| is the
@@ -180,7 +191,9 @@
       Register address,
       Register value,
       RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET,
-      SmiCheck smi_check = INLINE_SMI_CHECK);
+      SmiCheck smi_check = INLINE_SMI_CHECK,
+      PointersToHereCheck pointers_to_here_check_for_value =
+          kPointersToHereMaybeInteresting);

   // For page containing |object| mark the region covering the object's map
// dirty. |object| is the object being stored into, |map| is the Map object

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to