From 661630f589d4e07d067f210a629082a895731f70 Mon Sep 17 00:00:00 2001 From: "hpayer@chromium.org" Date: Wed, 25 Jun 2014 06:29:36 +0000 Subject: [PATCH] Update survival statistics correctly in the Scavenger. BUG= R=ishell@chromium.org Review URL: https://codereview.chromium.org/351893003 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21991 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/heap.cc | 84 +++++++++++++++++++++++++++++-------------------------------- 1 file changed, 40 insertions(+), 44 deletions(-) diff --git a/src/heap.cc b/src/heap.cc index 4dea510..627ea77 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -1986,17 +1986,14 @@ class ScavengingVisitor : public StaticVisitorBase { } Heap* heap = map->GetHeap(); - if (heap->ShouldBePromoted(object->address(), object_size)) { - AllocationResult allocation; + AllocationResult allocation; - if (object_contents == DATA_OBJECT) { - ASSERT(heap->AllowedToBeMigrated(object, OLD_DATA_SPACE)); - allocation = heap->old_data_space()->AllocateRaw(allocation_size); - } else { - ASSERT(heap->AllowedToBeMigrated(object, OLD_POINTER_SPACE)); - allocation = heap->old_pointer_space()->AllocateRaw(allocation_size); - } + if (!heap->ShouldBePromoted(object->address(), object_size)) { + ASSERT(heap->AllowedToBeMigrated(object, NEW_SPACE)); + allocation = heap->new_space()->AllocateRaw(allocation_size); + // Allocation in the other semi-space may fail due to fragmentation. + // In that case we allocate in the old generation. HeapObject* target = NULL; // Initialization to please compiler. if (allocation.To(&target)) { if (alignment != kObjectAlignment) { @@ -2009,49 +2006,48 @@ class ScavengingVisitor : public StaticVisitorBase { *slot = target; MigrateObject(heap, object, target, object_size); - if (object_contents == POINTER_OBJECT) { - if (map->instance_type() == JS_FUNCTION_TYPE) { - heap->promotion_queue()->insert( - target, JSFunction::kNonWeakFieldsEndOffset); - } else { - heap->promotion_queue()->insert(target, object_size); - } - } - - heap->IncrementPromotedObjectsSize(object_size); + heap->promotion_queue()->SetNewLimit(heap->new_space()->top()); + heap->IncrementSemiSpaceCopiedObjectSize(object_size); return; } } - ASSERT(heap->AllowedToBeMigrated(object, NEW_SPACE)); - AllocationResult allocation = - heap->new_space()->AllocateRaw(allocation_size); - heap->promotion_queue()->SetNewLimit(heap->new_space()->top()); - - // Allocation in the other semi-space may fail due to fragmentation. - // In that case we allocate in the old generation. - if (allocation.IsRetry()) { - if (object_contents == DATA_OBJECT) { - ASSERT(heap->AllowedToBeMigrated(object, OLD_DATA_SPACE)); - allocation = heap->old_data_space()->AllocateRaw(allocation_size); - } else { - ASSERT(heap->AllowedToBeMigrated(object, OLD_POINTER_SPACE)); - allocation = heap->old_pointer_space()->AllocateRaw(allocation_size); - } + + if (object_contents == DATA_OBJECT) { + ASSERT(heap->AllowedToBeMigrated(object, OLD_DATA_SPACE)); + allocation = heap->old_data_space()->AllocateRaw(allocation_size); + } else { + ASSERT(heap->AllowedToBeMigrated(object, OLD_POINTER_SPACE)); + allocation = heap->old_pointer_space()->AllocateRaw(allocation_size); } - HeapObject* target = HeapObject::cast(allocation.ToObjectChecked()); + HeapObject* target = NULL; // Initialization to please compiler. + if (allocation.To(&target)) { + if (alignment != kObjectAlignment) { + target = EnsureDoubleAligned(heap, target, allocation_size); + } - if (alignment != kObjectAlignment) { - target = EnsureDoubleAligned(heap, target, allocation_size); + // Order is important: slot might be inside of the target if target + // was allocated over a dead object and slot comes from the store + // buffer. + *slot = target; + MigrateObject(heap, object, target, object_size); + + if (object_contents == POINTER_OBJECT) { + if (map->instance_type() == JS_FUNCTION_TYPE) { + heap->promotion_queue()->insert(target, + JSFunction::kNonWeakFieldsEndOffset); + } else { + heap->promotion_queue()->insert(target, object_size); + } + } + + heap->IncrementPromotedObjectsSize(object_size); + return; } - // Order is important: slot might be inside of the target if target - // was allocated over a dead object and slot comes from the store - // buffer. - *slot = target; - MigrateObject(heap, object, target, object_size); - heap->IncrementSemiSpaceCopiedObjectSize(object_size); - return; + // The scavenger should always have enough space available in the old + // generation for promotion. Otherwise a full gc would have been triggered. + UNREACHABLE(); } -- 2.7.4