Commit ab8368df authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

[heap] Remove PagedSpace::SizeOfObjects

PagedSpace::SizeOfObjects() then returns exactly the same value as
PagedSpace::Size(). SizeOfObjects() used to deduct the current LAB,
however this is now more difficult with local heaps. Accessing the
main thread LAB from concurrent threads causes a data race. Also
LocalHeaps have their own LAB, which should be deducted as well to be
uniform with the main thread. However this would be tricky and expensive.
The simpler solution is to do not deduct the main thread LAB anymore.

Bug: v8:10315
Change-Id: I3c47e1a65caca9395737251aa694b295e78c7fb5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2336090
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69245}
parent c51041f4
......@@ -871,12 +871,6 @@ void PagedSpace::PrepareForMarkCompact() {
free_list_->Reset();
}
size_t PagedSpace::SizeOfObjects() {
CHECK_GE(limit(), top());
DCHECK_GE(Size(), static_cast<size_t>(limit() - top()));
return Size() - (limit() - top());
}
bool PagedSpace::RefillLabMain(int size_in_bytes, AllocationOrigin origin) {
VMState<GC> state(heap()->isolate());
RuntimeCallTimerScope runtime_timer(
......
......@@ -120,10 +120,6 @@ class V8_EXPORT_PRIVATE PagedSpace
// here.
size_t Size() override { return accounting_stats_.Size(); }
// As size, but the bytes in lazily swept pages are estimated and the bytes
// in the current linear allocation area are not included.
size_t SizeOfObjects() override;
// Wasted bytes in this space. These are just the bytes that were thrown away
// due to being too small to use for allocation.
virtual size_t Waste() { return free_list_->wasted_bytes(); }
......
......@@ -1644,6 +1644,9 @@ HEAP_TEST(TestSizeOfObjects) {
v8::V8::Initialize();
Isolate* isolate = CcTest::i_isolate();
Heap* heap = CcTest::heap();
// Disable LAB, such that calculations with SizeOfObjects() and object size
// are correct.
heap->DisableInlineAllocation();
MarkCompactCollector* collector = heap->mark_compact_collector();
// Get initial heap size after several full GCs, which will stabilize
......@@ -1889,6 +1892,9 @@ TEST(HeapNumberAlignment) {
TEST(TestSizeOfObjectsVsHeapObjectIteratorPrecision) {
CcTest::InitializeVM();
// Disable LAB, such that calculations with SizeOfObjects() and object size
// are correct.
CcTest::heap()->DisableInlineAllocation();
HeapObjectIterator iterator(CcTest::heap());
intptr_t size_of_objects_1 = CcTest::heap()->SizeOfObjects();
intptr_t size_of_objects_2 = 0;
......@@ -5302,6 +5308,9 @@ TEST(OldSpaceAllocationCounter) {
v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate();
Heap* heap = isolate->heap();
// Disable LAB, such that calculations with SizeOfObjects() and object size
// are correct.
heap->DisableInlineAllocation();
size_t counter1 = heap->OldGenerationAllocationCounter();
CcTest::CollectGarbage(NEW_SPACE);
CcTest::CollectGarbage(NEW_SPACE);
......@@ -5726,6 +5735,9 @@ Handle<FixedArray> ShrinkArrayAndCheckSize(Heap* heap, int length) {
CcTest::CollectAllGarbage();
}
heap->mark_compact_collector()->EnsureSweepingCompleted();
// Disable LAB, such that calculations with SizeOfObjects() and object size
// are correct.
heap->DisableInlineAllocation();
size_t size_before_allocation = heap->SizeOfObjects();
Handle<FixedArray> array =
heap->isolate()->factory()->NewFixedArray(length, AllocationType::kOld);
......
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