From fea1d2b1455307016e180e1598c7efb518aa0d6e Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Wed, 16 Jul 2014 13:36:46 +0000 Subject: [PATCH] Fix PagedSpace size accounting. R=hpayer@chromium.org Review URL: https://codereview.chromium.org/392163003 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22433 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/mark-compact.cc | 1 + src/spaces.h | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mark-compact.cc b/src/mark-compact.cc index 08cc803..9df3e6f 100644 --- a/src/mark-compact.cc +++ b/src/mark-compact.cc @@ -3947,6 +3947,7 @@ static intptr_t Free(PagedSpace* space, if (mode == MarkCompactCollector::SWEEP_ON_MAIN_THREAD) { return space->Free(start, size); } else { + // TODO(hpayer): account for wasted bytes in concurrent sweeping too. return size - free_list->Free(start, size); } } diff --git a/src/spaces.h b/src/spaces.h index efed18e..2e6c0b9 100644 --- a/src/spaces.h +++ b/src/spaces.h @@ -1457,9 +1457,8 @@ class AllocationStats BASE_EMBEDDED { // Waste free bytes (available -> waste). void WasteBytes(int size_in_bytes) { - size_ -= size_in_bytes; + ASSERT(size_in_bytes >= 0); waste_ += size_in_bytes; - ASSERT(size_ >= 0); } private: @@ -1857,7 +1856,8 @@ class PagedSpace : public Space { // no attempt to add area to free list is made. int Free(Address start, int size_in_bytes) { int wasted = free_list_.Free(start, size_in_bytes); - accounting_stats_.DeallocateBytes(size_in_bytes - wasted); + accounting_stats_.DeallocateBytes(size_in_bytes); + accounting_stats_.WasteBytes(wasted); return size_in_bytes - wasted; } -- 2.7.4