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() {
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);
}
......
......@@ -1975,7 +1975,7 @@ static void DiscoverGreyObjectsOnPage(MarkingDeque* marking_deque,
}
int MarkCompactCollector::DiscoverAndPromoteBlackObjectsOnPage(
int MarkCompactCollector::DiscoverAndEvacuateBlackObjectsOnPage(
NewSpace* new_space,
NewSpacePage* p) {
ASSERT(strcmp(Marking::kWhiteBitPattern, "00") == 0);
......@@ -2008,8 +2008,10 @@ int MarkCompactCollector::DiscoverAndPromoteBlackObjectsOnPage(
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 @@ void MarkCompactCollector::EvacuateNewSpace() {
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);
......
......@@ -870,7 +870,7 @@ class MarkCompactCollector {
// regions to each space's free list.
void SweepSpaces();
int DiscoverAndPromoteBlackObjectsOnPage(NewSpace* new_space,
int DiscoverAndEvacuateBlackObjectsOnPage(NewSpace* new_space,
NewSpacePage* p);
void EvacuateNewSpace();
......
......@@ -19878,6 +19878,7 @@ TEST(PersistentHandleInNewSpaceVisitor) {
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));
......
......@@ -4315,6 +4315,7 @@ TEST(ArrayShiftSweeping) {
"var tmp = new Array(100000);"
"array[0] = 10;"
"gc();"
"gc();"
"array.shift();"
"array;");
......
......@@ -92,7 +92,8 @@ TEST(Promotion) {
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));
......
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