Revision: 21915
Author:   [email protected]
Date:     Mon Jun 23 08:50:54 2014 UTC
Log: An object should only be promoted to the old generation if it survived a scavenge operation.

BUG=
[email protected]

Review URL: https://codereview.chromium.org/345523002
http://code.google.com/p/v8/source/detail?r=21915

Modified:
 /branches/bleeding_edge/src/heap-inl.h
 /branches/bleeding_edge/src/mark-compact.cc
 /branches/bleeding_edge/src/mark-compact.h
 /branches/bleeding_edge/test/cctest/test-api.cc
 /branches/bleeding_edge/test/cctest/test-heap.cc
 /branches/bleeding_edge/test/cctest/test-mark-compact.cc

=======================================
--- /branches/bleeding_edge/src/heap-inl.h      Fri Jun 20 07:35:48 2014 UTC
+++ /branches/bleeding_edge/src/heap-inl.h      Mon Jun 23 08:50:54 2014 UTC
@@ -388,15 +388,12 @@


 bool Heap::ShouldBePromoted(Address old_address, int object_size) {
-  // An object should be promoted if:
-  // - the object has survived a scavenge operation or
-  // - to space is already 25% full.
+  // An object should be promoted if the object has survived a
+  // scavenge operation.
   NewSpacePage* page = NewSpacePage::FromAddress(old_address);
   Address age_mark = new_space_.age_mark();
- bool below_mark = page->IsFlagSet(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK) &&
+  return page->IsFlagSet(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK) &&
       (!page->ContainsLimit(age_mark) || old_address < age_mark);
-  return below_mark || (new_space_.Size() + object_size) >=
-                        (new_space_.EffectiveCapacity() >> 2);
 }


=======================================
--- /branches/bleeding_edge/src/mark-compact.cc Fri Jun 20 07:35:48 2014 UTC
+++ /branches/bleeding_edge/src/mark-compact.cc Mon Jun 23 08:50:54 2014 UTC
@@ -1975,7 +1975,7 @@
 }


-int MarkCompactCollector::DiscoverAndPromoteBlackObjectsOnPage(
+int MarkCompactCollector::DiscoverAndEvacuateBlackObjectsOnPage(
     NewSpace* new_space,
     NewSpacePage* p) {
   ASSERT(strcmp(Marking::kWhiteBitPattern, "00") == 0);
@@ -2008,8 +2008,10 @@

       offset++;
       current_cell >>= 1;
-      // Aggressively promote young survivors to the old space.
-      if (TryPromoteObject(object, size)) {
+
+ // TODO(hpayer): Refactor EvacuateObject and call this function instead.
+      if (heap()->ShouldBePromoted(object->address(), size) &&
+          TryPromoteObject(object, size)) {
         continue;
       }

@@ -3049,7 +3051,7 @@
   NewSpacePageIterator it(from_bottom, from_top);
   while (it.has_next()) {
     NewSpacePage* p = it.next();
-    survivors_size += DiscoverAndPromoteBlackObjectsOnPage(new_space, p);
+    survivors_size += DiscoverAndEvacuateBlackObjectsOnPage(new_space, p);
   }

   heap_->IncrementYoungSurvivorsCounter(survivors_size);
=======================================
--- /branches/bleeding_edge/src/mark-compact.h  Tue Jun  3 17:37:33 2014 UTC
+++ /branches/bleeding_edge/src/mark-compact.h  Mon Jun 23 08:50:54 2014 UTC
@@ -870,7 +870,7 @@
   // regions to each space's free list.
   void SweepSpaces();

-  int DiscoverAndPromoteBlackObjectsOnPage(NewSpace* new_space,
+  int DiscoverAndEvacuateBlackObjectsOnPage(NewSpace* new_space,
                                            NewSpacePage* p);

   void EvacuateNewSpace();
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Fri Jun 20 08:40:11 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-api.cc Mon Jun 23 08:50:54 2014 UTC
@@ -19878,6 +19878,7 @@
   object1.SetWrapperClassId(42);
   CHECK_EQ(42, object1.WrapperClassId());

+  CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
   CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);

   v8::Persistent<v8::Object> object2(isolate, v8::Object::New(isolate));
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap.cc Fri Jun 13 16:43:27 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-heap.cc Mon Jun 23 08:50:54 2014 UTC
@@ -4315,6 +4315,7 @@
       "var tmp = new Array(100000);"
       "array[0] = 10;"
       "gc();"
+      "gc();"
       "array.shift();"
       "array;");

=======================================
--- /branches/bleeding_edge/test/cctest/test-mark-compact.cc Fri Jun 20 08:40:11 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-mark-compact.cc Mon Jun 23 08:50:54 2014 UTC
@@ -92,7 +92,8 @@
   CHECK(heap->InSpace(*array, NEW_SPACE));

   // Call mark compact GC, so array becomes an old object.
-  heap->CollectGarbage(OLD_POINTER_SPACE);
+  heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+  heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);

   // Array now sits in the old space
   CHECK(heap->InSpace(*array, OLD_POINTER_SPACE));

--
--
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