@@ -17656,152 +17656,6 @@ TEST(GetHeapSpaceStatistics) {
1765617656 CHECK_EQ(total_physical_size, heap_statistics.total_physical_size());
1765717657}
1765817658
17659- UNINITIALIZED_TEST(GetHeapTotalAllocatedBytes) {
17660- // This test is incompatible with concurrent allocation, which may occur
17661- // while collecting the statistics and break the final `CHECK_EQ`s.
17662- if (i::v8_flags.stress_concurrent_allocation) return;
17663-
17664- v8::Isolate::CreateParams create_params;
17665- create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
17666- v8::Isolate* isolate = v8::Isolate::New(create_params);
17667-
17668- const uint32_t number_of_elements = 1;
17669- const uint32_t allocation_size = i::FixedArray::SizeFor(number_of_elements);
17670- const uint32_t trusted_allocation_size =
17671- i::TrustedFixedArray::SizeFor(number_of_elements);
17672- const uint32_t lo_number_of_elements = 256 * 1024;
17673- const uint32_t lo_allocation_size =
17674- i::FixedArray::SizeFor(lo_number_of_elements);
17675- const uint32_t trusted_lo_allocation_size =
17676- i::TrustedFixedArray::SizeFor(lo_number_of_elements);
17677- const uint32_t expected_allocation_size =
17678- allocation_size * 2 + lo_allocation_size * 2 + trusted_allocation_size +
17679- trusted_lo_allocation_size;
17680-
17681- {
17682- v8::Isolate::Scope isolate_scope(isolate);
17683- v8::HandleScope handle_scope(isolate);
17684- LocalContext env(isolate);
17685- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
17686-
17687- v8::HeapStatistics heap_stats_before;
17688- isolate->GetHeapStatistics(&heap_stats_before);
17689- size_t initial_allocated = heap_stats_before.total_allocated_bytes();
17690-
17691- i::MaybeHandle<i::FixedArray> young_alloc =
17692- i_isolate->factory()->TryNewFixedArray(number_of_elements,
17693- i::AllocationType::kYoung);
17694- USE(young_alloc);
17695- i::MaybeHandle<i::FixedArray> old_alloc =
17696- i_isolate->factory()->TryNewFixedArray(number_of_elements,
17697- i::AllocationType::kOld);
17698- USE(old_alloc);
17699- i::Handle<i::TrustedFixedArray> trusted_alloc =
17700- i_isolate->factory()->NewTrustedFixedArray(number_of_elements,
17701- i::AllocationType::kTrusted);
17702- USE(trusted_alloc);
17703- i::MaybeHandle<i::FixedArray> old_lo_alloc =
17704- i_isolate->factory()->TryNewFixedArray(lo_number_of_elements,
17705- i::AllocationType::kOld);
17706- USE(old_lo_alloc);
17707-
17708- {
17709- v8::HandleScope inner_handle_scope(isolate);
17710- auto young_lo_alloc = i_isolate->factory()->TryNewFixedArray(
17711- lo_number_of_elements, i::AllocationType::kYoung);
17712- USE(young_lo_alloc);
17713- }
17714-
17715- auto trusted_lo_alloc = i_isolate->factory()->NewTrustedFixedArray(
17716- lo_number_of_elements, i::AllocationType::kTrusted);
17717- USE(trusted_lo_alloc);
17718-
17719- v8::HeapStatistics heap_stats_after;
17720- isolate->GetHeapStatistics(&heap_stats_after);
17721- uint64_t final_allocated = heap_stats_after.total_allocated_bytes();
17722-
17723- CHECK_GT(final_allocated, initial_allocated);
17724- uint64_t allocated_diff = final_allocated - initial_allocated;
17725- CHECK_GE(allocated_diff, expected_allocation_size);
17726-
17727- // This either tests counting happening when a LAB freed and validate
17728- // there's no double counting on evacuated/promoted objects.
17729- v8::internal::heap::InvokeAtomicMajorGC(i_isolate->heap());
17730-
17731- v8::HeapStatistics heap_stats_after_gc;
17732- isolate->GetHeapStatistics(&heap_stats_after_gc);
17733- uint64_t total_allocation_after_gc =
17734- heap_stats_after_gc.total_allocated_bytes();
17735-
17736- CHECK_EQ(total_allocation_after_gc, final_allocated);
17737- }
17738-
17739- isolate->Dispose();
17740- }
17741-
17742- #if V8_CAN_CREATE_SHARED_HEAP_BOOL
17743-
17744- UNINITIALIZED_TEST(GetHeapTotalAllocatedBytesSharedSpaces) {
17745- // This test is incompatible with concurrent allocation, which may occur
17746- // while collecting the statistics and break the final `CHECK_EQ`s.
17747- if (i::v8_flags.stress_concurrent_allocation) return;
17748- if (COMPRESS_POINTERS_IN_MULTIPLE_CAGES_BOOL) return;
17749-
17750- i::v8_flags.shared_heap = true;
17751- i::FlagList::EnforceFlagImplications();
17752-
17753- v8::Isolate::CreateParams create_params;
17754- create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
17755- v8::Isolate* isolate = v8::Isolate::New(create_params);
17756-
17757- {
17758- v8::Isolate::Scope isolate_scope(isolate);
17759- v8::HandleScope handle_scope(isolate);
17760- LocalContext env(isolate);
17761-
17762- v8::HeapStatistics heap_stats_before;
17763- isolate->GetHeapStatistics(&heap_stats_before);
17764- size_t initial_allocated = heap_stats_before.total_allocated_bytes();
17765-
17766- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
17767-
17768- const uint32_t number_of_elements = 1;
17769- const uint32_t allocation_size = i::FixedArray::SizeFor(number_of_elements);
17770- const uint32_t trusted_allocation_size =
17771- i::TrustedFixedArray::SizeFor(number_of_elements);
17772- const uint32_t lo_number_of_elements = 256 * 1024;
17773- const uint32_t lo_allocation_size =
17774- i::FixedArray::SizeFor(lo_number_of_elements);
17775- const uint32_t expected_allocation_size =
17776- allocation_size + trusted_allocation_size + lo_allocation_size;
17777-
17778- i::MaybeHandle<i::FixedArray> shared_alloc =
17779- i_isolate->factory()->TryNewFixedArray(number_of_elements,
17780- i::AllocationType::kSharedOld);
17781- USE(shared_alloc);
17782- i::Handle<i::TrustedFixedArray> shared_trusted_alloc =
17783- i_isolate->factory()->NewTrustedFixedArray(
17784- number_of_elements, i::AllocationType::kSharedTrusted);
17785- USE(shared_trusted_alloc);
17786- i::MaybeHandle<i::FixedArray> shared_lo_alloc =
17787- i_isolate->factory()->TryNewFixedArray(lo_number_of_elements,
17788- i::AllocationType::kSharedOld);
17789- USE(shared_lo_alloc);
17790-
17791- v8::HeapStatistics heap_stats_after;
17792- isolate->GetHeapStatistics(&heap_stats_after);
17793- uint64_t final_allocated = heap_stats_after.total_allocated_bytes();
17794-
17795- CHECK_GT(final_allocated, initial_allocated);
17796- uint64_t allocated_diff = final_allocated - initial_allocated;
17797- CHECK_GE(allocated_diff, expected_allocation_size);
17798- }
17799-
17800- isolate->Dispose();
17801- }
17802-
17803- #endif // V8_CAN_CREATE_SHARED_HEAP_BOOL
17804-
1780517659TEST(NumberOfNativeContexts) {
1780617660 static const size_t kNumTestContexts = 10;
1780717661 i::Isolate* isolate = CcTest::i_isolate();
0 commit comments