Reviewers: Vyacheslav Egorov,

Description:
Rescan cells at the end of mark-sweep.  This means they don't need a
write barrier.

Please review this at http://codereview.chromium.org/8816021/

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/ia32/code-stubs-ia32.cc
  M     src/ia32/lithium-codegen-ia32.cc
  M     src/ia32/stub-cache-ia32.cc
  M     src/mark-compact.cc


Index: src/ia32/code-stubs-ia32.cc
===================================================================
--- src/ia32/code-stubs-ia32.cc (revision 10174)
+++ src/ia32/code-stubs-ia32.cc (working copy)
@@ -4653,7 +4653,8 @@
     // megamorphic.
     __ cmp(ecx, Immediate(UninitializedSentinel(isolate)));
     __ j(equal, &initialize, Label::kNear);
-    // MegamorphicSentinel is a root so no write-barrier is needed.
+ // MegamorphicSentinel is an immortal immovable object (undefined) so no
+    // write-barrier is needed.
     __ mov(FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset),
            Immediate(MegamorphicSentinel(isolate)));
     __ jmp(&call, Label::kNear);
@@ -4661,14 +4662,7 @@
     // An uninitialized cache is patched with the function.
     __ bind(&initialize);
     __ mov(FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset), edi);
-    __ mov(ecx, edi);
-    __ RecordWriteField(ebx,
-                        JSGlobalPropertyCell::kValueOffset,
-                        ecx,
-                        edx,
-                        kDontSaveFPRegs,
-                        OMIT_REMEMBERED_SET,  // Cells are rescanned.
-                        OMIT_SMI_CHECK);
+    // No need for a write barrier here - cells are rescanned.

     __ bind(&call);
   }
@@ -4700,6 +4694,8 @@
     // non-function case.
     __ mov(ebx, Operand(esp, 0));
     __ mov(ebx, Operand(ebx, 1));
+ // MegamorphicSentinel is an immortal immovable object (undefined) so no
+    // write barrier is needed.
     __ mov(FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset),
            Immediate(MegamorphicSentinel(isolate)));
   }
Index: src/ia32/lithium-codegen-ia32.cc
===================================================================
--- src/ia32/lithium-codegen-ia32.cc    (revision 10174)
+++ src/ia32/lithium-codegen-ia32.cc    (working copy)
@@ -2144,20 +2144,7 @@

   // Store the value.
   __ mov(FieldOperand(object, offset), value);
-
-  // Cells are always in the remembered set.
-  if (instr->hydrogen()->NeedsWriteBarrier()) {
-    HType type = instr->hydrogen()->value()->type();
-    SmiCheck check_needed =
-        type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
-    __ RecordWriteField(object,
-                        offset,
-                        value,
-                        address,
-                        kSaveFPRegs,
-                        OMIT_REMEMBERED_SET,
-                        check_needed);
-  }
+  // Cells are always rescanned, so no write barrier here.
 }


Index: src/ia32/stub-cache-ia32.cc
===================================================================
--- src/ia32/stub-cache-ia32.cc (revision 10174)
+++ src/ia32/stub-cache-ia32.cc (working copy)
@@ -2522,23 +2522,9 @@

   // Store the value in the cell.
   __ mov(cell_operand, eax);
-  Label done;
-  __ test(eax, Immediate(kSmiTagMask));
-  __ j(zero, &done);
+  // No write barrier here, because cells are always rescanned.

-  __ mov(ecx, eax);
-  __ lea(edx, cell_operand);
-  // Cells are always in the remembered set.
-  __ RecordWrite(ebx,  // Object.
-                 edx,  // Address.
-                 ecx,  // Value.
-                 kDontSaveFPRegs,
-                 OMIT_REMEMBERED_SET,
-                 OMIT_SMI_CHECK);
-
   // Return the value (register eax).
-  __ bind(&done);
-
   Counters* counters = isolate()->counters();
   __ IncrementCounter(counters->named_store_global_inline(), 1);
   __ ret(0);
Index: src/mark-compact.cc
===================================================================
--- src/mark-compact.cc (revision 10174)
+++ src/mark-compact.cc (working copy)
@@ -2081,6 +2081,22 @@

   PrepareForCodeFlushing();

+ // There is no write barrier on cells so we have to scan them now at the end
+  // of the incremental sweeping.
+  {
+    HeapObjectIterator cell_iterator(heap()->cell_space());
+    HeapObject* cell;
+    while ((cell = cell_iterator.Next()) != NULL) {
+      ASSERT(cell->IsJSGlobalPropertyCell());
+      if (IsMarked(cell)) {
+        int offset = JSGlobalPropertyCell::kValueOffset;
+        StaticMarkingVisitor::VisitPointer(
+            heap(),
+            reinterpret_cast<Object**>(cell->address() + offset));
+      }
+    }
+  }
+
   RootMarkingVisitor root_visitor(heap());
   MarkRoots(&root_visitor);



--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to