Commit 100b9d83 authored by hpayer@chromium.org's avatar hpayer@chromium.org

An object should only be promoted to the old generation if it survived a scavenge operation.

BUG=
R=mstarzinger@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21915 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2c8eef08
...@@ -388,15 +388,12 @@ bool Heap::OldGenerationAllocationLimitReached() { ...@@ -388,15 +388,12 @@ bool Heap::OldGenerationAllocationLimitReached() {
bool Heap::ShouldBePromoted(Address old_address, int object_size) { bool Heap::ShouldBePromoted(Address old_address, int object_size) {
// An object should be promoted if: // An object should be promoted if the object has survived a
// - the object has survived a scavenge operation or // scavenge operation.
// - to space is already 25% full.
NewSpacePage* page = NewSpacePage::FromAddress(old_address); NewSpacePage* page = NewSpacePage::FromAddress(old_address);
Address age_mark = new_space_.age_mark(); 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); (!page->ContainsLimit(age_mark) || old_address < age_mark);
return below_mark || (new_space_.Size() + object_size) >=
(new_space_.EffectiveCapacity() >> 2);
} }
......
...@@ -1975,7 +1975,7 @@ static void DiscoverGreyObjectsOnPage(MarkingDeque* marking_deque, ...@@ -1975,7 +1975,7 @@ static void DiscoverGreyObjectsOnPage(MarkingDeque* marking_deque,
} }
int MarkCompactCollector::DiscoverAndPromoteBlackObjectsOnPage( int MarkCompactCollector::DiscoverAndEvacuateBlackObjectsOnPage(
NewSpace* new_space, NewSpace* new_space,
NewSpacePage* p) { NewSpacePage* p) {
ASSERT(strcmp(Marking::kWhiteBitPattern, "00") == 0); ASSERT(strcmp(Marking::kWhiteBitPattern, "00") == 0);
...@@ -2008,8 +2008,10 @@ int MarkCompactCollector::DiscoverAndPromoteBlackObjectsOnPage( ...@@ -2008,8 +2008,10 @@ int MarkCompactCollector::DiscoverAndPromoteBlackObjectsOnPage(
offset++; offset++;
current_cell >>= 1; 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; continue;
} }
...@@ -3049,7 +3051,7 @@ void MarkCompactCollector::EvacuateNewSpace() { ...@@ -3049,7 +3051,7 @@ void MarkCompactCollector::EvacuateNewSpace() {
NewSpacePageIterator it(from_bottom, from_top); NewSpacePageIterator it(from_bottom, from_top);
while (it.has_next()) { while (it.has_next()) {
NewSpacePage* p = it.next(); NewSpacePage* p = it.next();
survivors_size += DiscoverAndPromoteBlackObjectsOnPage(new_space, p); survivors_size += DiscoverAndEvacuateBlackObjectsOnPage(new_space, p);
} }
heap_->IncrementYoungSurvivorsCounter(survivors_size); heap_->IncrementYoungSurvivorsCounter(survivors_size);
......
...@@ -870,7 +870,7 @@ class MarkCompactCollector { ...@@ -870,7 +870,7 @@ class MarkCompactCollector {
// regions to each space's free list. // regions to each space's free list.
void SweepSpaces(); void SweepSpaces();
int DiscoverAndPromoteBlackObjectsOnPage(NewSpace* new_space, int DiscoverAndEvacuateBlackObjectsOnPage(NewSpace* new_space,
NewSpacePage* p); NewSpacePage* p);
void EvacuateNewSpace(); void EvacuateNewSpace();
......
...@@ -19878,6 +19878,7 @@ TEST(PersistentHandleInNewSpaceVisitor) { ...@@ -19878,6 +19878,7 @@ TEST(PersistentHandleInNewSpaceVisitor) {
object1.SetWrapperClassId(42); object1.SetWrapperClassId(42);
CHECK_EQ(42, object1.WrapperClassId()); CHECK_EQ(42, object1.WrapperClassId());
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
v8::Persistent<v8::Object> object2(isolate, v8::Object::New(isolate)); v8::Persistent<v8::Object> object2(isolate, v8::Object::New(isolate));
......
...@@ -4315,6 +4315,7 @@ TEST(ArrayShiftSweeping) { ...@@ -4315,6 +4315,7 @@ TEST(ArrayShiftSweeping) {
"var tmp = new Array(100000);" "var tmp = new Array(100000);"
"array[0] = 10;" "array[0] = 10;"
"gc();" "gc();"
"gc();"
"array.shift();" "array.shift();"
"array;"); "array;");
......
...@@ -92,7 +92,8 @@ TEST(Promotion) { ...@@ -92,7 +92,8 @@ TEST(Promotion) {
CHECK(heap->InSpace(*array, NEW_SPACE)); CHECK(heap->InSpace(*array, NEW_SPACE));
// Call mark compact GC, so array becomes an old object. // 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 // Array now sits in the old space
CHECK(heap->InSpace(*array, OLD_POINTER_SPACE)); CHECK(heap->InSpace(*array, OLD_POINTER_SPACE));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment