diff --git a/src/heap/heap.cc b/src/heap/heap.cc index afdc7bb4cd..b8a9b7a50c 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -3078,9 +3078,11 @@ void Heap::AdjustLiveBytes(HeapObject* object, int by, InvocationMode mode) { // the heap using HeapIterator, we can update the live byte count. We cannot // update while using HeapIterator because the iterator is temporarily // marking the whole object graph, without updating live bytes. - if (!in_heap_iterator() && - !mark_compact_collector()->sweeping_in_progress() && - Marking::IsBlack(Marking::MarkBitFrom(object->address()))) { + if (lo_space()->Contains(object)) { + lo_space()->AdjustLiveBytes(by); + } else if (!in_heap_iterator() && + !mark_compact_collector()->sweeping_in_progress() && + Marking::IsBlack(Marking::MarkBitFrom(object->address()))) { if (mode == SEQUENTIAL_TO_SWEEPER) { MemoryChunk::IncrementLiveBytesFromGC(object, by); } else { diff --git a/src/heap/spaces.h b/src/heap/spaces.h index c8c4d3f5bb..67e9aae114 100644 --- a/src/heap/spaces.h +++ b/src/heap/spaces.h @@ -3057,6 +3057,8 @@ class LargeObjectSpace : public Space { // Checks whether the space is empty. bool IsEmpty() { return first_page_ == NULL; } + void AdjustLiveBytes(int by) { objects_size_ += by; } + LargePage* first_page() { return first_page_; } #ifdef VERIFY_HEAP diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc index 030ef5c616..14c91153c7 100644 --- a/test/cctest/heap/test-heap.cc +++ b/test/cctest/heap/test-heap.cc @@ -6743,5 +6743,18 @@ TEST(Regress598319) { } } +TEST(Regress609761) { + CcTest::InitializeVM(); + v8::HandleScope scope(CcTest::isolate()); + Heap* heap = CcTest::heap(); + Isolate* isolate = heap->isolate(); + + intptr_t size_before = heap->SizeOfObjects(); + Handle array = isolate->factory()->NewFixedArray(200000); + array->Shrink(1); + intptr_t size_after = heap->SizeOfObjects(); + CHECK_EQ(size_after, size_before + array->Size()); +} + } // namespace internal } // namespace v8