From 2cd77745d92044e77ec6b91cbf04d9132b639742 Mon Sep 17 00:00:00 2001 From: Wenyu Zhao Date: Wed, 21 Apr 2021 10:32:15 +1000 Subject: [PATCH] [heap] Fix failed tests when enabling single generation * Filtered some tests that rely on incremental_marking and shape tracking Bug: v8:11644 Change-Id: Ic9833bf1e49e6413422484858cd1054dd2500092 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2822284 Commit-Queue: Wenyu Zhao Reviewed-by: Ulan Degenbaev Cr-Commit-Position: refs/heads/master@{#74078} --- BUILD.gn | 1 + src/heap/factory.cc | 10 +++++----- src/heap/new-spaces-inl.h | 1 + src/runtime/runtime-test.cc | 1 + test/cctest/heap/heap-utils.cc | 3 ++- test/cctest/heap/test-array-buffer-tracker.cc | 9 +++++---- test/cctest/heap/test-concurrent-allocation.cc | 3 +++ test/cctest/heap/test-concurrent-marking.cc | 2 ++ test/cctest/heap/test-embedder-tracing.cc | 2 ++ test/cctest/heap/test-heap.cc | 7 +++++++ test/cctest/heap/test-invalidated-slots.cc | 4 ++++ test/cctest/heap/test-mark-compact.cc | 1 + test/cctest/heap/test-spaces.cc | 4 ++++ test/cctest/heap/test-write-barrier.cc | 2 ++ test/cctest/test-serialize.cc | 1 + test/mjsunit/mjsunit.status | 16 ++++++++++++++++ test/unittests/heap/unified-heap-unittest.cc | 2 ++ tools/testrunner/base_runner.py | 2 ++ .../testdata/testroot1/v8_build_config.json | 1 + .../testdata/testroot2/v8_build_config.json | 1 + 20 files changed, 63 insertions(+), 10 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 98cec64d62..7eabcd5b60 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1928,6 +1928,7 @@ action("v8_dump_build_config") { "v8_enable_atomic_object_field_writes=" + "$v8_enable_atomic_object_field_writes", "v8_enable_concurrent_marking=$v8_enable_concurrent_marking", + "v8_enable_single_generation=$v8_enable_single_generation", "v8_enable_i18n_support=$v8_enable_i18n_support", "v8_enable_verify_predictable=$v8_enable_verify_predictable", "v8_enable_verify_csa=$v8_enable_verify_csa", diff --git a/src/heap/factory.cc b/src/heap/factory.cc index cfd45f7b39..a1310f8480 100644 --- a/src/heap/factory.cc +++ b/src/heap/factory.cc @@ -1181,7 +1181,7 @@ Handle Factory::NewCatchContext(Handle previous, isolate()->catch_context_map(), Context::SizeFor(variadic_part_length), variadic_part_length, AllocationType::kYoung); DisallowGarbageCollection no_gc; - DCHECK(Heap::InYoungGeneration(context)); + DCHECK_IMPLIES(!FLAG_single_generation, Heap::InYoungGeneration(context)); context.set_scope_info(*scope_info, SKIP_WRITE_BARRIER); context.set_previous(*previous, SKIP_WRITE_BARRIER); context.set(Context::THROWN_OBJECT_INDEX, *thrown_object, SKIP_WRITE_BARRIER); @@ -1206,7 +1206,7 @@ Handle Factory::NewDebugEvaluateContext(Handle previous, Context::SizeFor(variadic_part_length), variadic_part_length, AllocationType::kYoung); DisallowGarbageCollection no_gc; - DCHECK(Heap::InYoungGeneration(context)); + DCHECK_IMPLIES(!FLAG_single_generation, Heap::InYoungGeneration(context)); context.set_scope_info(*scope_info, SKIP_WRITE_BARRIER); context.set_previous(*previous, SKIP_WRITE_BARRIER); context.set_extension(*ext, SKIP_WRITE_BARRIER); @@ -1229,7 +1229,7 @@ Handle Factory::NewWithContext(Handle previous, isolate()->with_context_map(), Context::SizeFor(variadic_part_length), variadic_part_length, AllocationType::kYoung); DisallowGarbageCollection no_gc; - DCHECK(Heap::InYoungGeneration(context)); + DCHECK_IMPLIES(!FLAG_single_generation, Heap::InYoungGeneration(context)); context.set_scope_info(*scope_info, SKIP_WRITE_BARRIER); context.set_previous(*previous, SKIP_WRITE_BARRIER); context.set_extension(*extension, SKIP_WRITE_BARRIER); @@ -1245,7 +1245,7 @@ Handle Factory::NewBlockContext(Handle previous, isolate()->block_context_map(), Context::SizeFor(variadic_part_length), variadic_part_length, AllocationType::kYoung); DisallowGarbageCollection no_gc; - DCHECK(Heap::InYoungGeneration(context)); + DCHECK_IMPLIES(!FLAG_single_generation, Heap::InYoungGeneration(context)); context.set_scope_info(*scope_info, SKIP_WRITE_BARRIER); context.set_previous(*previous, SKIP_WRITE_BARRIER); return handle(context, isolate()); @@ -1258,7 +1258,7 @@ Handle Factory::NewBuiltinContext(Handle native_context, isolate()->function_context_map(), Context::SizeFor(variadic_part_length), variadic_part_length, AllocationType::kYoung); DisallowGarbageCollection no_gc; - DCHECK(Heap::InYoungGeneration(context)); + DCHECK_IMPLIES(!FLAG_single_generation, Heap::InYoungGeneration(context)); context.set_scope_info(read_only_roots().empty_scope_info(), SKIP_WRITE_BARRIER); context.set_previous(*native_context, SKIP_WRITE_BARRIER); diff --git a/src/heap/new-spaces-inl.h b/src/heap/new-spaces-inl.h index ffd5d8cfd7..0f3b4c1b55 100644 --- a/src/heap/new-spaces-inl.h +++ b/src/heap/new-spaces-inl.h @@ -87,6 +87,7 @@ HeapObject SemiSpaceObjectIterator::Next() { AllocationResult NewSpace::AllocateRaw(int size_in_bytes, AllocationAlignment alignment, AllocationOrigin origin) { + DCHECK(!FLAG_single_generation); #if DEBUG VerifyTop(); #endif diff --git a/src/runtime/runtime-test.cc b/src/runtime/runtime-test.cc index 07e003f1a6..5a3cf9b950 100644 --- a/src/runtime/runtime-test.cc +++ b/src/runtime/runtime-test.cc @@ -715,6 +715,7 @@ int FixedArrayLenFromSize(int size) { } void FillUpOneNewSpacePage(Isolate* isolate, Heap* heap) { + DCHECK(!FLAG_single_generation); PauseAllocationObserversScope pause_observers(heap); NewSpace* space = heap->new_space(); // We cannot rely on `space->limit()` to point to the end of the current page diff --git a/test/cctest/heap/heap-utils.cc b/test/cctest/heap/heap-utils.cc index 24f04e9eed..f94bc1fa5e 100644 --- a/test/cctest/heap/heap-utils.cc +++ b/test/cctest/heap/heap-utils.cc @@ -122,7 +122,8 @@ std::vector> CreatePadding(Heap* heap, int padding_size, CHECK((allocation == AllocationType::kYoung && heap->new_space()->Contains(*handles.back())) || (allocation == AllocationType::kOld && - heap->InOldSpace(*handles.back()))); + heap->InOldSpace(*handles.back())) || + FLAG_single_generation); free_memory -= handles.back()->Size(); } return handles; diff --git a/test/cctest/heap/test-array-buffer-tracker.cc b/test/cctest/heap/test-array-buffer-tracker.cc index d9407a25c0..c5ca0dbb9c 100644 --- a/test/cctest/heap/test-array-buffer-tracker.cc +++ b/test/cctest/heap/test-array-buffer-tracker.cc @@ -398,15 +398,16 @@ TEST(ArrayBuffer_ExternalBackingStoreSizeIncreases) { Heap* heap = reinterpret_cast(isolate)->heap(); ExternalBackingStoreType type = ExternalBackingStoreType::kArrayBuffer; - const size_t backing_store_before = - heap->new_space()->ExternalBackingStoreBytes(type); + const Space* space = FLAG_incremental_marking + ? static_cast(heap->new_space()) + : static_cast(heap->old_space()); + const size_t backing_store_before = space->ExternalBackingStoreBytes(type); { const size_t kArraybufferSize = 117; v8::HandleScope handle_scope(isolate); Local ab = v8::ArrayBuffer::New(isolate, kArraybufferSize); USE(ab); - const size_t backing_store_after = - heap->new_space()->ExternalBackingStoreBytes(type); + const size_t backing_store_after = space->ExternalBackingStoreBytes(type); CHECK_EQ(kArraybufferSize, backing_store_after - backing_store_before); } } diff --git a/test/cctest/heap/test-concurrent-allocation.cc b/test/cctest/heap/test-concurrent-allocation.cc index 1a664b9562..f819383815 100644 --- a/test/cctest/heap/test-concurrent-allocation.cc +++ b/test/cctest/heap/test-concurrent-allocation.cc @@ -340,6 +340,7 @@ class ConcurrentBlackAllocationThread final : public v8::base::Thread { }; UNINITIALIZED_TEST(ConcurrentBlackAllocation) { + if (!FLAG_incremental_marking) return; v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); v8::Isolate* isolate = v8::Isolate::New(create_params); @@ -399,6 +400,7 @@ class ConcurrentWriteBarrierThread final : public v8::base::Thread { }; UNINITIALIZED_TEST(ConcurrentWriteBarrier) { + if (!FLAG_incremental_marking) return; if (!FLAG_concurrent_marking) { // The test requires concurrent marking barrier. return; @@ -463,6 +465,7 @@ class ConcurrentRecordRelocSlotThread final : public v8::base::Thread { }; UNINITIALIZED_TEST(ConcurrentRecordRelocSlot) { + if (!FLAG_incremental_marking) return; if (!FLAG_concurrent_marking) { // The test requires concurrent marking barrier. return; diff --git a/test/cctest/heap/test-concurrent-marking.cc b/test/cctest/heap/test-concurrent-marking.cc index 5387bf9dad..c5bb234c70 100644 --- a/test/cctest/heap/test-concurrent-marking.cc +++ b/test/cctest/heap/test-concurrent-marking.cc @@ -104,6 +104,7 @@ TEST(ConcurrentMarkingPreemptAndReschedule) { } TEST(ConcurrentMarkingMarkedBytes) { + if (!FLAG_incremental_marking) return; if (!i::FLAG_concurrent_marking) return; CcTest::InitializeVM(); Isolate* isolate = CcTest::i_isolate(); @@ -124,6 +125,7 @@ TEST(ConcurrentMarkingMarkedBytes) { } UNINITIALIZED_TEST(ConcurrentMarkingStoppedOnTeardown) { + if (!FLAG_incremental_marking) return; if (!i::FLAG_concurrent_marking) return; v8::Isolate::CreateParams create_params; diff --git a/test/cctest/heap/test-embedder-tracing.cc b/test/cctest/heap/test-embedder-tracing.cc index 6b5ebb4bc8..097d1aa509 100644 --- a/test/cctest/heap/test-embedder-tracing.cc +++ b/test/cctest/heap/test-embedder-tracing.cc @@ -251,6 +251,7 @@ TEST(FinalizeTracingIsNoopWhenNotMarking) { } TEST(FinalizeTracingWhenMarking) { + if (!FLAG_incremental_marking) return; ManualGCScope manual_gc; CcTest::InitializeVM(); v8::Isolate* isolate = CcTest::isolate(); @@ -709,6 +710,7 @@ TEST(TracedGlobalSetFinalizationCallbackMarkSweep) { TEST(TracePrologueCallingIntoV8WriteBarrier) { // Regression test: https://crbug.com/940003 + if (!FLAG_incremental_marking) return; ManualGCScope manual_gc; CcTest::InitializeVM(); v8::Isolate* isolate = CcTest::isolate(); diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc index 18cb2a6b32..fc768dc4c9 100644 --- a/test/cctest/heap/test-heap.cc +++ b/test/cctest/heap/test-heap.cc @@ -1265,6 +1265,7 @@ UNINITIALIZED_TEST(Regress10843) { // Tests that spill slots from optimized code don't have weak pointers. TEST(Regress10774) { + if (FLAG_single_generation) return; i::FLAG_allow_natives_syntax = true; i::FLAG_turboprop = true; i::FLAG_turbo_dynamic_map_checks = true; @@ -1325,6 +1326,7 @@ TEST(Regress10774) { #ifndef V8_LITE_MODE TEST(TestOptimizeAfterBytecodeFlushingCandidate) { + if (FLAG_single_generation) return; FLAG_opt = true; FLAG_always_opt = false; #if ENABLE_SPARKPLUG @@ -1803,6 +1805,7 @@ static Address AlignNewSpace(AllocationAlignment alignment, int offset) { TEST(TestAlignedAllocation) { + if (FLAG_single_generation) return; // Double misalignment is 4 on 32-bit platforms or when pointer compression // is enabled, 0 on 64-bit ones when pointer compression is disabled. const intptr_t double_misalignment = kDoubleSize - kTaggedSize; @@ -6583,6 +6586,7 @@ HEAP_TEST(RegressMissingWriteBarrierInAllocate) { } HEAP_TEST(MarkCompactEpochCounter) { + if (!FLAG_incremental_marking) return; ManualGCScope manual_gc_scope; CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); @@ -6949,6 +6953,7 @@ TEST(Regress8014) { } TEST(Regress8617) { + if (!FLAG_incremental_marking) return; ManualGCScope manual_gc_scope; FLAG_manual_evacuation_candidates_selection = true; LocalContext env; @@ -6991,6 +6996,7 @@ TEST(Regress8617) { } HEAP_TEST(MemoryReducerActivationForSmallHeaps) { + if (FLAG_single_generation) return; ManualGCScope manual_gc_scope; LocalContext env; Isolate* isolate = CcTest::i_isolate(); @@ -7160,6 +7166,7 @@ TEST(GarbageCollectionWithLocalHeap) { } TEST(Regress10698) { + if (!FLAG_incremental_marking) return; CcTest::InitializeVM(); Heap* heap = CcTest::i_isolate()->heap(); Factory* factory = CcTest::i_isolate()->factory(); diff --git a/test/cctest/heap/test-invalidated-slots.cc b/test/cctest/heap/test-invalidated-slots.cc index af4ddfddfd..c212e37589 100644 --- a/test/cctest/heap/test-invalidated-slots.cc +++ b/test/cctest/heap/test-invalidated-slots.cc @@ -199,6 +199,7 @@ Handle AllocateArrayOnEvacuationCandidate(Isolate* isolate, } HEAP_TEST(InvalidatedSlotsRightTrimFixedArray) { + if (!FLAG_incremental_marking) return; FLAG_manual_evacuation_candidates_selection = true; FLAG_parallel_compaction = false; ManualGCScope manual_gc_scope; @@ -230,6 +231,7 @@ HEAP_TEST(InvalidatedSlotsRightTrimFixedArray) { } HEAP_TEST(InvalidatedSlotsRightTrimLargeFixedArray) { + if (!FLAG_incremental_marking) return; FLAG_manual_evacuation_candidates_selection = true; FLAG_parallel_compaction = false; ManualGCScope manual_gc_scope; @@ -267,6 +269,7 @@ HEAP_TEST(InvalidatedSlotsRightTrimLargeFixedArray) { } HEAP_TEST(InvalidatedSlotsLeftTrimFixedArray) { + if (!FLAG_incremental_marking) return; FLAG_manual_evacuation_candidates_selection = true; FLAG_parallel_compaction = false; ManualGCScope manual_gc_scope; @@ -298,6 +301,7 @@ HEAP_TEST(InvalidatedSlotsLeftTrimFixedArray) { } HEAP_TEST(InvalidatedSlotsFastToSlow) { + if (!FLAG_incremental_marking) return; FLAG_manual_evacuation_candidates_selection = true; FLAG_parallel_compaction = false; ManualGCScope manual_gc_scope; diff --git a/test/cctest/heap/test-mark-compact.cc b/test/cctest/heap/test-mark-compact.cc index dc1771ce75..6183ae3218 100644 --- a/test/cctest/heap/test-mark-compact.cc +++ b/test/cctest/heap/test-mark-compact.cc @@ -427,6 +427,7 @@ UNINITIALIZED_TEST(RegressJoinThreadsOnIsolateDeinit) { } TEST(Regress5829) { + if (!FLAG_incremental_marking) return; FLAG_stress_concurrent_allocation = false; // For SealCurrentObjects. CcTest::InitializeVM(); Isolate* isolate = CcTest::i_isolate(); diff --git a/test/cctest/heap/test-spaces.cc b/test/cctest/heap/test-spaces.cc index 5326c53644..16b9644e9c 100644 --- a/test/cctest/heap/test-spaces.cc +++ b/test/cctest/heap/test-spaces.cc @@ -269,6 +269,7 @@ TEST(ComputeDiscardMemoryAreas) { } TEST(NewSpace) { + if (FLAG_single_generation) return; Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); TestMemoryAllocatorScope test_allocator_scope(isolate, heap->MaxReserved(), @@ -516,6 +517,7 @@ void testAllocationObserver(Isolate* i_isolate, T* space) { } UNINITIALIZED_TEST(AllocationObserver) { + if (FLAG_single_generation) return; v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); v8::Isolate* isolate = v8::Isolate::New(create_params); @@ -538,6 +540,7 @@ UNINITIALIZED_TEST(AllocationObserver) { } UNINITIALIZED_TEST(InlineAllocationObserverCadence) { + if (FLAG_single_generation) return; v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); v8::Isolate* isolate = v8::Isolate::New(create_params); @@ -617,6 +620,7 @@ HEAP_TEST(Regress777177) { } HEAP_TEST(Regress791582) { + if (FLAG_single_generation) return; CcTest::InitializeVM(); Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); diff --git a/test/cctest/heap/test-write-barrier.cc b/test/cctest/heap/test-write-barrier.cc index a73b9e82b1..3027fe860d 100644 --- a/test/cctest/heap/test-write-barrier.cc +++ b/test/cctest/heap/test-write-barrier.cc @@ -16,6 +16,7 @@ namespace internal { namespace heap { HEAP_TEST(WriteBarrier_Marking) { + if (!FLAG_incremental_marking) return; ManualGCScope manual_gc_scope; CcTest::InitializeVM(); Isolate* isolate = CcTest::i_isolate(); @@ -56,6 +57,7 @@ HEAP_TEST(WriteBarrier_Marking) { } HEAP_TEST(WriteBarrier_MarkingExtension) { + if (!FLAG_incremental_marking) return; ManualGCScope manual_gc_scope; CcTest::InitializeVM(); Isolate* isolate = CcTest::i_isolate(); diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc index 2884dfd136..5fbc9600e1 100644 --- a/test/cctest/test-serialize.cc +++ b/test/cctest/test-serialize.cc @@ -1849,6 +1849,7 @@ TEST(CodeSerializerLargeCodeObject) { } TEST(CodeSerializerLargeCodeObjectWithIncrementalMarking) { + if (!FLAG_incremental_marking) return; if (FLAG_never_compact) return; ManualGCScope manual_gc_scope; FLAG_always_opt = false; diff --git a/test/mjsunit/mjsunit.status b/test/mjsunit/mjsunit.status index 3635e06421..9b57e7495c 100644 --- a/test/mjsunit/mjsunit.status +++ b/test/mjsunit/mjsunit.status @@ -1480,4 +1480,20 @@ 'regress/wasm/regress-1010272': [SKIP], }], +################################################################################ +['single_generation', { + # These tests rely on allocation site tracking which only works in the young generation. + 'array-constructor-feedback': [SKIP], + 'wasm/generic-wrapper': [SKIP], + 'regress/regress-trap-allocation-memento': [SKIP], + 'regress/regress-crbug-1151890': [SKIP], + 'regress/regress-crbug-1163184': [SKIP], + 'regress/regress-11519': [SKIP], + 'regress/regress-4121': [SKIP], + 'packed-elements': [SKIP], + 'const-dict-tracking': [SKIP], + 'compiler/native-context-specialization-hole-check': [SKIP], + 'compiler/test-literal-map-migration': [SKIP], +}], # single_generation + ] diff --git a/test/unittests/heap/unified-heap-unittest.cc b/test/unittests/heap/unified-heap-unittest.cc index 404cf2e1a0..1c9e6946e5 100644 --- a/test/unittests/heap/unified-heap-unittest.cc +++ b/test/unittests/heap/unified-heap-unittest.cc @@ -66,6 +66,7 @@ TEST_F(UnifiedHeapTest, FindingV8ToBlinkReference) { } TEST_F(UnifiedHeapTest, WriteBarrierV8ToCppReference) { + if (!FLAG_incremental_marking) return; v8::HandleScope scope(v8_isolate()); v8::Local context = v8::Context::New(v8_isolate()); v8::Context::Scope context_scope(context); @@ -92,6 +93,7 @@ TEST_F(UnifiedHeapTest, WriteBarrierV8ToCppReference) { } TEST_F(UnifiedHeapTest, WriteBarrierCppToV8Reference) { + if (!FLAG_incremental_marking) return; v8::HandleScope scope(v8_isolate()); v8::Local context = v8::Context::New(v8_isolate()); v8::Context::Scope context_scope(context); diff --git a/tools/testrunner/base_runner.py b/tools/testrunner/base_runner.py index 34d5421f82..5ed80311af 100644 --- a/tools/testrunner/base_runner.py +++ b/tools/testrunner/base_runner.py @@ -172,6 +172,7 @@ class BuildConfig(object): self.cfi_vptr = build_config['is_cfi'] self.control_flow_integrity = build_config['v8_control_flow_integrity'] self.concurrent_marking = build_config['v8_enable_concurrent_marking'] + self.single_generation = build_config['v8_enable_single_generation'] self.dcheck_always_on = build_config['dcheck_always_on'] self.gcov_coverage = build_config['is_gcov_coverage'] self.is_android = build_config['is_android'] @@ -664,6 +665,7 @@ class BaseTestRunner(object): "cfi_vptr": self.build_config.cfi_vptr, "control_flow_integrity": self.build_config.control_flow_integrity, "concurrent_marking": self.build_config.concurrent_marking, + "single_generation": self.build_config.single_generation, "dcheck_always_on": self.build_config.dcheck_always_on, "deopt_fuzzer": False, "endurance_fuzzer": False, diff --git a/tools/unittests/testdata/testroot1/v8_build_config.json b/tools/unittests/testdata/testroot1/v8_build_config.json index 9bf6bd1ee4..04ccbb1600 100644 --- a/tools/unittests/testdata/testroot1/v8_build_config.json +++ b/tools/unittests/testdata/testroot1/v8_build_config.json @@ -23,6 +23,7 @@ "v8_enable_pointer_compression": true, "v8_enable_pointer_compression_shared_cage": true, "v8_control_flow_integrity": false, + "v8_enable_single_generation": false, "v8_enable_third_party_heap": false, "v8_enable_webassembly": true } diff --git a/tools/unittests/testdata/testroot2/v8_build_config.json b/tools/unittests/testdata/testroot2/v8_build_config.json index 50517b3dc8..b3e36ef6de 100644 --- a/tools/unittests/testdata/testroot2/v8_build_config.json +++ b/tools/unittests/testdata/testroot2/v8_build_config.json @@ -23,6 +23,7 @@ "v8_enable_pointer_compression": false, "v8_enable_pointer_compression_shared_cage": false, "v8_control_flow_integrity": false, + "v8_enable_single_generation": false, "v8_enable_third_party_heap": false, "v8_enable_webassembly": true }