diff --git a/src/api/api.cc b/src/api/api.cc index fa6ac0acf0..7da75131fb 100644 --- a/src/api/api.cc +++ b/src/api/api.cc @@ -617,7 +617,10 @@ StartupData SnapshotCreator::CreateBlob( i::Snapshot::ClearReconstructableDataForSerialization( i_isolate, function_code_handling == FunctionCodeHandling::kClear); - i::GlobalSafepointScope global_safepoint(i_isolate); + i::SafepointKind safepoint_kind = i_isolate->has_shared_heap() + ? i::SafepointKind::kGlobal + : i::SafepointKind::kIsolate; + i::SafepointScope safepoint_scope(i_isolate, safepoint_kind); i::DisallowGarbageCollection no_gc_from_here_on; // Create a vector with all contexts and clear associated Persistent fields. @@ -655,7 +658,7 @@ StartupData SnapshotCreator::CreateBlob( data->created_ = true; return i::Snapshot::Create(i_isolate, &contexts, embedder_fields_serializers, - global_safepoint, no_gc_from_here_on); + safepoint_scope, no_gc_from_here_on); } bool StartupData::CanBeRehashed() const { diff --git a/src/heap/combined-heap.h b/src/heap/combined-heap.h index 4e88f49514..7a7e30a8a8 100644 --- a/src/heap/combined-heap.h +++ b/src/heap/combined-heap.h @@ -26,7 +26,7 @@ class V8_EXPORT_PRIVATE CombinedHeapObjectIterator final { HeapObject Next(); private: - SafepointScope safepoint_scope_; + IsolateSafepointScope safepoint_scope_; HeapObjectIterator heap_iterator_; ReadOnlyHeapObjectIterator ro_heap_iterator_; }; diff --git a/src/heap/heap-verifier.cc b/src/heap/heap-verifier.cc index 5783927a6b..42c6c64550 100644 --- a/src/heap/heap-verifier.cc +++ b/src/heap/heap-verifier.cc @@ -73,7 +73,7 @@ void HeapVerification::Verify() { CHECK(heap()->HasBeenSetUp()); AllowGarbageCollection allow_gc; IgnoreLocalGCRequests ignore_gc_requests(heap()); - SafepointScope safepoint_scope(heap()); + IsolateSafepointScope safepoint_scope(heap()); HandleScope scope(isolate()); heap()->MakeHeapIterable(); diff --git a/src/heap/heap.cc b/src/heap/heap.cc index eca7a8c3e7..da1b958e13 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -1841,18 +1841,16 @@ void Heap::StartIncrementalMarking(int gc_flags, CompleteSweepingFull(); } - base::Optional global_safepoint_scope; base::Optional safepoint_scope; { AllowGarbageCollection allow_shared_gc; IgnoreLocalGCRequests ignore_gc_requests(this); - if (isolate()->is_shared_heap_isolate()) { - global_safepoint_scope.emplace(isolate()); - } else { - safepoint_scope.emplace(this); - } + SafepointKind safepoint_kind = isolate()->is_shared_heap_isolate() + ? SafepointKind::kGlobal + : SafepointKind::kIsolate; + safepoint_scope.emplace(isolate(), safepoint_kind); } #ifdef DEBUG @@ -2165,18 +2163,17 @@ size_t Heap::PerformGarbageCollection( DCHECK(tracer()->IsConsistentWithCollector(collector)); TRACE_GC_EPOCH(tracer(), CollectorScopeId(collector), ThreadKind::kMain); - base::Optional global_safepoint_scope; - base::Optional isolate_safepoint_scope; + base::Optional safepoint_scope; { AllowGarbageCollection allow_shared_gc; IgnoreLocalGCRequests ignore_gc_requests(this); - if (isolate()->is_shared_heap_isolate()) { - global_safepoint_scope.emplace(isolate()); - } else { - isolate_safepoint_scope.emplace(this); - } + SafepointKind safepoint_kind = + v8_flags.shared_space && isolate()->is_shared_heap_isolate() + ? SafepointKind::kGlobal + : SafepointKind::kIsolate; + safepoint_scope.emplace(isolate(), safepoint_kind); } collection_barrier_->StopTimeToCollectionTimer(); @@ -3433,7 +3430,7 @@ FixedArrayBase Heap::LeftTrimFixedArray(FixedArrayBase object, if (v8_flags.enable_slow_asserts) { // Make sure the stack or other roots (e.g., Handles) don't contain pointers // to the original FixedArray (which is now the filler object). - base::Optional safepoint_scope; + base::Optional safepoint_scope; { AllowGarbageCollection allow_gc; @@ -4201,7 +4198,7 @@ std::unique_ptr Heap::MeasureMemoryDelegate( void Heap::CollectCodeStatistics() { TRACE_EVENT0("v8", "Heap::CollectCodeStatistics"); IgnoreLocalGCRequests ignore_gc_requests(this); - SafepointScope safepoint_scope(this); + IsolateSafepointScope safepoint_scope(this); MakeHeapIterable(); CodeStatistics::ResetCodeAndMetadataStatistics(isolate()); // We do not look for code in new space, or map space. If code @@ -6401,7 +6398,7 @@ class UnreachableObjectsFilter : public HeapObjectsFilter { HeapObjectIterator::HeapObjectIterator( Heap* heap, HeapObjectIterator::HeapObjectsFiltering filtering) : heap_(heap), - safepoint_scope_(std::make_unique(heap)), + safepoint_scope_(std::make_unique(heap)), filtering_(filtering), filter_(nullptr), space_iterator_(nullptr), diff --git a/src/heap/heap.h b/src/heap/heap.h index 78883f1586..06dab6b069 100644 --- a/src/heap/heap.h +++ b/src/heap/heap.h @@ -105,6 +105,7 @@ class HeapObjectAllocationTracker; class HeapObjectsFilter; class HeapStats; class Isolate; +class IsolateSafepointScope; class JSFinalizationRegistry; class LinearAllocationArea; class LocalEmbedderHeapTracer; @@ -123,7 +124,6 @@ class PagedNewSpace; class ReadOnlyHeap; class RootVisitor; class RwxMemoryWriteScope; -class SafepointScope; class ScavengeJob; class Scavenger; class ScavengerCollector; @@ -2751,7 +2751,7 @@ class V8_EXPORT_PRIVATE HeapObjectIterator { HeapObject NextObject(); Heap* heap_; - std::unique_ptr safepoint_scope_; + std::unique_ptr safepoint_scope_; HeapObjectsFiltering filtering_; HeapObjectsFilter* filter_; // Space iterator for iterating all the spaces. diff --git a/src/heap/local-heap.h b/src/heap/local-heap.h index 4e6437669a..3d42f4091a 100644 --- a/src/heap/local-heap.h +++ b/src/heap/local-heap.h @@ -335,11 +335,11 @@ class V8_EXPORT_PRIVATE LocalHeap { friend class CollectionBarrier; friend class ConcurrentAllocator; friend class GlobalSafepoint; - friend class IsolateSafepoint; friend class Heap; friend class Isolate; + friend class IsolateSafepoint; + friend class IsolateSafepointScope; friend class ParkedScope; - friend class SafepointScope; friend class UnparkedScope; }; diff --git a/src/heap/safepoint.cc b/src/heap/safepoint.cc index ea36ba296d..a08f75d3d8 100644 --- a/src/heap/safepoint.cc +++ b/src/heap/safepoint.cc @@ -282,11 +282,14 @@ Isolate* IsolateSafepoint::shared_heap_isolate() const { return isolate()->shared_heap_isolate(); } -SafepointScope::SafepointScope(Heap* heap) : safepoint_(heap->safepoint()) { +IsolateSafepointScope::IsolateSafepointScope(Heap* heap) + : safepoint_(heap->safepoint()) { safepoint_->EnterLocalSafepointScope(); } -SafepointScope::~SafepointScope() { safepoint_->LeaveLocalSafepointScope(); } +IsolateSafepointScope::~IsolateSafepointScope() { + safepoint_->LeaveLocalSafepointScope(); +} GlobalSafepoint::GlobalSafepoint(Isolate* isolate) : shared_heap_isolate_(isolate) {} @@ -415,23 +418,22 @@ void GlobalSafepoint::LeaveGlobalSafepointScope(Isolate* initiator) { GlobalSafepointScope::GlobalSafepointScope(Isolate* initiator) : initiator_(initiator), - shared_heap_isolate_(initiator->has_shared_heap() - ? initiator->shared_heap_isolate() - : nullptr) { - if (shared_heap_isolate_) { - shared_heap_isolate_->global_safepoint()->EnterGlobalSafepointScope( - initiator_); - } else { - initiator_->heap()->safepoint()->EnterLocalSafepointScope(); - } + shared_heap_isolate_(initiator->shared_heap_isolate()) { + shared_heap_isolate_->global_safepoint()->EnterGlobalSafepointScope( + initiator_); } GlobalSafepointScope::~GlobalSafepointScope() { - if (shared_heap_isolate_) { - shared_heap_isolate_->global_safepoint()->LeaveGlobalSafepointScope( - initiator_); + shared_heap_isolate_->global_safepoint()->LeaveGlobalSafepointScope( + initiator_); +} + +SafepointScope::SafepointScope(Isolate* initiator, SafepointKind kind) { + if (kind == SafepointKind::kIsolate) { + isolate_safepoint_.emplace(initiator->heap()); } else { - initiator_->heap()->safepoint()->LeaveLocalSafepointScope(); + DCHECK_EQ(kind, SafepointKind::kGlobal); + global_safepoint_.emplace(initiator); } } diff --git a/src/heap/safepoint.h b/src/heap/safepoint.h index 97e0e54591..7e935889b7 100644 --- a/src/heap/safepoint.h +++ b/src/heap/safepoint.h @@ -148,14 +148,14 @@ class IsolateSafepoint final { friend class GlobalSafepoint; friend class GlobalSafepointScope; friend class Isolate; + friend class IsolateSafepointScope; friend class LocalHeap; - friend class SafepointScope; }; -class V8_NODISCARD SafepointScope { +class V8_NODISCARD IsolateSafepointScope { public: - V8_EXPORT_PRIVATE explicit SafepointScope(Heap* heap); - V8_EXPORT_PRIVATE ~SafepointScope(); + V8_EXPORT_PRIVATE explicit IsolateSafepointScope(Heap* heap); + V8_EXPORT_PRIVATE ~IsolateSafepointScope(); private: IsolateSafepoint* safepoint_; @@ -204,6 +204,18 @@ class V8_NODISCARD GlobalSafepointScope { Isolate* const shared_heap_isolate_; }; +enum class SafepointKind { kIsolate, kGlobal }; + +class V8_NODISCARD SafepointScope { + public: + V8_EXPORT_PRIVATE explicit SafepointScope(Isolate* initiator, + SafepointKind kind); + + private: + base::Optional isolate_safepoint_; + base::Optional global_safepoint_; +}; + } // namespace internal } // namespace v8 diff --git a/src/profiler/heap-snapshot-generator.cc b/src/profiler/heap-snapshot-generator.cc index 6e9ace40be..5ee9fd8edd 100644 --- a/src/profiler/heap-snapshot-generator.cc +++ b/src/profiler/heap-snapshot-generator.cc @@ -2463,7 +2463,7 @@ void V8HeapExplorer::CollectGlobalObjectsTags() { } void V8HeapExplorer::MakeGlobalObjectTagMap( - const SafepointScope& safepoint_scope) { + const IsolateSafepointScope& safepoint_scope) { for (const auto& pair : global_object_tag_pairs_) { global_object_tag_map_.emplace(*pair.first, pair.second); } @@ -2723,7 +2723,7 @@ bool HeapSnapshotGenerator::GenerateSnapshot() { heap_->CollectAllAvailableGarbage(GarbageCollectionReason::kHeapProfiler); NullContextForSnapshotScope null_context_scope(isolate); - SafepointScope scope(heap_); + IsolateSafepointScope scope(heap_); v8_heap_explorer_.MakeGlobalObjectTagMap(scope); handle_scope.reset(); diff --git a/src/profiler/heap-snapshot-generator.h b/src/profiler/heap-snapshot-generator.h index 7750c2b5c2..4237475590 100644 --- a/src/profiler/heap-snapshot-generator.h +++ b/src/profiler/heap-snapshot-generator.h @@ -36,6 +36,7 @@ class HeapEntry; class HeapProfiler; class HeapSnapshot; class HeapSnapshotGenerator; +class IsolateSafepointScope; class JSArrayBuffer; class JSCollection; class JSGeneratorObject; @@ -43,7 +44,6 @@ class JSGlobalObject; class JSGlobalProxy; class JSPromise; class JSWeakCollection; -class SafepointScope; struct SourceLocation { SourceLocation(int entry_index, int scriptId, int line, int col) @@ -390,7 +390,7 @@ class V8_EXPORT_PRIVATE V8HeapExplorer : public HeapEntriesAllocator { uint32_t EstimateObjectsCount(); bool IterateAndExtractReferences(HeapSnapshotGenerator* generator); void CollectGlobalObjectsTags(); - void MakeGlobalObjectTagMap(const SafepointScope& safepoint_scope); + void MakeGlobalObjectTagMap(const IsolateSafepointScope& safepoint_scope); void TagBuiltinCodeObject(CodeT code, const char* name); HeapEntry* AddEntry(Address address, HeapEntry::Type type, diff --git a/src/snapshot/snapshot.cc b/src/snapshot/snapshot.cc index aa6e34a7e5..d7461ac0bb 100644 --- a/src/snapshot/snapshot.cc +++ b/src/snapshot/snapshot.cc @@ -315,7 +315,10 @@ void Snapshot::SerializeDeserializeAndVerifyForTesting( // Test serialization. { - GlobalSafepointScope global_safepoint(isolate); + SafepointKind safepoint_kind = isolate->has_shared_heap() + ? SafepointKind::kGlobal + : SafepointKind::kIsolate; + SafepointScope safepoint_scope(isolate, safepoint_kind); DisallowGarbageCollection no_gc; Snapshot::SerializerFlags flags( @@ -325,7 +328,7 @@ void Snapshot::SerializeDeserializeAndVerifyForTesting( ? Snapshot::kReconstructReadOnlyAndSharedObjectCachesForTesting : 0)); serialized_data = Snapshot::Create(isolate, *default_context, - global_safepoint, no_gc, flags); + safepoint_scope, no_gc, flags); auto_delete_serialized_data.reset(serialized_data.data); } @@ -369,14 +372,14 @@ v8::StartupData Snapshot::Create( Isolate* isolate, std::vector* contexts, const std::vector& embedder_fields_serializers, - const GlobalSafepointScope& global_safepoint, + const SafepointScope& safepoint_scope, const DisallowGarbageCollection& no_gc, SerializerFlags flags) { TRACE_EVENT0("v8", "V8.SnapshotCreate"); DCHECK_EQ(contexts->size(), embedder_fields_serializers.size()); DCHECK_GT(contexts->size(), 0); HandleScope scope(isolate); - // The GlobalSafepointScope ensures we are in a safepoint scope so that the + // The HeapSafepointScope ensures we are in a safepoint scope so that the // string table is safe to iterate. Unlike mksnapshot, embedders may have // background threads running. @@ -453,13 +456,13 @@ v8::StartupData Snapshot::Create( // static v8::StartupData Snapshot::Create(Isolate* isolate, Context default_context, - const GlobalSafepointScope& global_safepoint, + const SafepointScope& safepoint_scope, const DisallowGarbageCollection& no_gc, SerializerFlags flags) { std::vector contexts{default_context}; std::vector callbacks{{}}; - return Snapshot::Create(isolate, &contexts, callbacks, global_safepoint, - no_gc, flags); + return Snapshot::Create(isolate, &contexts, callbacks, safepoint_scope, no_gc, + flags); } v8::StartupData SnapshotImpl::CreateSnapshotBlob( diff --git a/src/snapshot/snapshot.h b/src/snapshot/snapshot.h index 6e85d91242..88fa61aab8 100644 --- a/src/snapshot/snapshot.h +++ b/src/snapshot/snapshot.h @@ -15,10 +15,10 @@ namespace v8 { namespace internal { class Context; -class GlobalSafepointScope; class Isolate; -class SnapshotData; class JSGlobalProxy; +class SafepointScope; +class SnapshotData; class Snapshot : public AllStatic { public: @@ -69,14 +69,14 @@ class Snapshot : public AllStatic { Isolate* isolate, std::vector* contexts, const std::vector& embedder_fields_serializers, - const GlobalSafepointScope& global_safepoint, + const SafepointScope& safepoint_scope, const DisallowGarbageCollection& no_gc, SerializerFlags flags = kDefaultSerializerFlags); // Convenience helper for the above when only serializing a single context. static v8::StartupData Create( Isolate* isolate, Context default_context, - const GlobalSafepointScope& global_safepoint, + const SafepointScope& safepoint_scope, const DisallowGarbageCollection& no_gc, SerializerFlags flags = kDefaultSerializerFlags); diff --git a/test/cctest/heap/heap-utils.cc b/test/cctest/heap/heap-utils.cc index 5027118f5b..6c1ae2dc05 100644 --- a/test/cctest/heap/heap-utils.cc +++ b/test/cctest/heap/heap-utils.cc @@ -263,7 +263,7 @@ void SimulateIncrementalMarking(i::Heap* heap, bool force_completion) { i::IncrementalMarking* marking = heap->incremental_marking(); if (heap->sweeping_in_progress()) { - SafepointScope scope(heap); + IsolateSafepointScope scope(heap); heap->EnsureSweepingCompleted( Heap::SweepingForcedFinalizationMode::kV8Only); } @@ -282,7 +282,7 @@ void SimulateIncrementalMarking(i::Heap* heap, bool force_completion) { CHECK(marking->IsMarking()); if (!force_completion) return; - SafepointScope scope(heap); + IsolateSafepointScope scope(heap); MarkingBarrier::PublishAll(heap); marking->MarkRootsForTesting(); @@ -315,7 +315,7 @@ void AbandonCurrentlyFreeMemory(PagedSpace* space) { void GcAndSweep(Heap* heap, AllocationSpace space) { heap->CollectGarbage(space, GarbageCollectionReason::kTesting); if (heap->sweeping_in_progress()) { - SafepointScope scope(heap); + IsolateSafepointScope scope(heap); heap->EnsureSweepingCompleted( Heap::SweepingForcedFinalizationMode::kV8Only); } @@ -343,14 +343,14 @@ bool InCorrectGeneration(HeapObject object) { } void GrowNewSpace(Heap* heap) { - SafepointScope scope(heap); + IsolateSafepointScope scope(heap); if (!heap->new_space()->IsAtMaximumCapacity()) { heap->new_space()->Grow(); } } void GrowNewSpaceToMaximumCapacity(Heap* heap) { - SafepointScope scope(heap); + IsolateSafepointScope scope(heap); while (!heap->new_space()->IsAtMaximumCapacity()) { heap->new_space()->Grow(); } diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc index 481d2ee23b..46516735d2 100644 --- a/test/cctest/heap/test-heap.cc +++ b/test/cctest/heap/test-heap.cc @@ -5860,7 +5860,7 @@ TEST(Regress598319) { } } - SafepointScope safepoint_scope(heap); + IsolateSafepointScope safepoint_scope(heap); MarkingBarrier::PublishAll(heap); // Finish marking with bigger steps to speed up test. @@ -6566,7 +6566,7 @@ HEAP_TEST(Regress670675) { heap->tracer()->StopFullCycleIfNeeded(); i::IncrementalMarking* marking = CcTest::heap()->incremental_marking(); if (marking->IsStopped()) { - SafepointScope safepoint_scope(heap); + IsolateSafepointScope safepoint_scope(heap); heap->tracer()->StartCycle( GarbageCollector::MARK_COMPACTOR, GarbageCollectionReason::kTesting, "collector cctest", GCTracer::MarkingType::kIncremental); diff --git a/test/cctest/heap/test-incremental-marking.cc b/test/cctest/heap/test-incremental-marking.cc index d6ec98d90f..77d769a52e 100644 --- a/test/cctest/heap/test-incremental-marking.cc +++ b/test/cctest/heap/test-incremental-marking.cc @@ -118,7 +118,7 @@ TEST_WITH_PLATFORM(IncrementalMarkingUsingTasks, MockPlatform) { i::IncrementalMarking* marking = heap->incremental_marking(); marking->Stop(); { - SafepointScope scope(heap); + IsolateSafepointScope scope(heap); heap->tracer()->StartCycle( GarbageCollector::MARK_COMPACTOR, GarbageCollectionReason::kTesting, "collector cctest", GCTracer::MarkingType::kIncremental); diff --git a/test/cctest/heap/test-spaces.cc b/test/cctest/heap/test-spaces.cc index bfa96eee84..b4fcef531f 100644 --- a/test/cctest/heap/test-spaces.cc +++ b/test/cctest/heap/test-spaces.cc @@ -161,7 +161,7 @@ static unsigned int PseudorandomAreaSize() { TEST(MemoryChunk) { Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); - SafepointScope safepoint(heap); + IsolateSafepointScope safepoint(heap); v8::PageAllocator* page_allocator = GetPlatformPageAllocator(); size_t area_size; diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc index d9df36b85b..87291a7529 100644 --- a/test/cctest/test-serialize.cc +++ b/test/cctest/test-serialize.cc @@ -210,7 +210,7 @@ static StartupBlobs Serialize(v8::Isolate* isolate) { Isolate* i_isolate = reinterpret_cast(isolate); CcTest::CollectAllAvailableGarbage(i_isolate); - SafepointScope safepoint(i_isolate->heap()); + IsolateSafepointScope safepoint(i_isolate->heap()); HandleScope scope(i_isolate); DisallowGarbageCollection no_gc; @@ -403,7 +403,7 @@ static void SerializeContext(base::Vector* startup_blob_out, env.Reset(); - SafepointScope safepoint(heap); + IsolateSafepointScope safepoint(heap); DisallowGarbageCollection no_gc; SnapshotByteSink read_only_sink; @@ -572,7 +572,7 @@ static void SerializeCustomContext( env.Reset(); - SafepointScope safepoint(isolate->heap()); + IsolateSafepointScope safepoint(isolate->heap()); DisallowGarbageCollection no_gc; SnapshotByteSink read_only_sink; diff --git a/test/mkgrokdump/mkgrokdump.cc b/test/mkgrokdump/mkgrokdump.cc index 6c4341756d..7ddd1c0893 100644 --- a/test/mkgrokdump/mkgrokdump.cc +++ b/test/mkgrokdump/mkgrokdump.cc @@ -127,7 +127,7 @@ static int DumpHeapConstants(FILE* out, const char* argv0) { { Isolate::Scope scope(isolate); i::Heap* heap = reinterpret_cast(isolate)->heap(); - i::SafepointScope safepoint_scope(heap); + i::IsolateSafepointScope safepoint_scope(heap); i::ReadOnlyHeap* read_only_heap = reinterpret_cast(isolate)->read_only_heap(); i::PrintF(out, "%s", kHeader); diff --git a/test/unittests/heap/embedder-tracing-unittest.cc b/test/unittests/heap/embedder-tracing-unittest.cc index 30c1ed64d0..39b9712bc6 100644 --- a/test/unittests/heap/embedder-tracing-unittest.cc +++ b/test/unittests/heap/embedder-tracing-unittest.cc @@ -466,7 +466,7 @@ TEST_F(EmbedderTracingTest, FinalizeTracingWhenMarking) { i::IncrementalMarking* marking = heap->incremental_marking(); { - SafepointScope scope(heap); + IsolateSafepointScope scope(heap); heap->tracer()->StartCycle( GarbageCollector::MARK_COMPACTOR, GarbageCollectionReason::kTesting, "collector cctest", GCTracer::MarkingType::kIncremental); diff --git a/test/unittests/heap/heap-unittest.cc b/test/unittests/heap/heap-unittest.cc index 94199af239..bd9a01a33e 100644 --- a/test/unittests/heap/heap-unittest.cc +++ b/test/unittests/heap/heap-unittest.cc @@ -162,7 +162,7 @@ TEST_F(HeapTest, HeapLayout) { base::AddressRegion heap_reservation(cage_base, size_t{4} * GB); base::AddressRegion code_reservation(code_cage_base, size_t{4} * GB); - SafepointScope scope(i_isolate()->heap()); + IsolateSafepointScope scope(i_isolate()->heap()); OldGenerationMemoryChunkIterator iter(i_isolate()->heap()); for (;;) { MemoryChunk* chunk = iter.next(); @@ -373,7 +373,7 @@ TEST_F(HeapTest, RememberedSet_InsertOnPromotingObjectToOld) { CHECK(!new_space->IsAtMaximumCapacity()); // Fill current pages to force MinorMC to promote them. SimulateFullSpace(new_space, &handles); - SafepointScope scope(heap); + IsolateSafepointScope scope(heap); // New empty pages should remain in new space. new_space->Grow(); } else { @@ -422,7 +422,7 @@ TEST_F(HeapTest, Regress978156) { // 5. Start incremental marking. i::IncrementalMarking* marking = heap->incremental_marking(); if (marking->IsStopped()) { - SafepointScope scope(heap); + IsolateSafepointScope scope(heap); heap->tracer()->StartCycle( GarbageCollector::MARK_COMPACTOR, GarbageCollectionReason::kTesting, "collector cctest", GCTracer::MarkingType::kIncremental); diff --git a/test/unittests/heap/heap-utils.cc b/test/unittests/heap/heap-utils.cc index f92137c0e7..10a09036aa 100644 --- a/test/unittests/heap/heap-utils.cc +++ b/test/unittests/heap/heap-utils.cc @@ -24,7 +24,7 @@ void HeapInternalsBase::SimulateIncrementalMarking(Heap* heap, i::IncrementalMarking* marking = heap->incremental_marking(); if (heap->sweeping_in_progress()) { - SafepointScope scope(heap); + IsolateSafepointScope scope(heap); heap->EnsureSweepingCompleted( Heap::SweepingForcedFinalizationMode::kV8Only); } diff --git a/test/unittests/heap/heap-utils.h b/test/unittests/heap/heap-utils.h index 6a111aaa80..0b09b1c78b 100644 --- a/test/unittests/heap/heap-utils.h +++ b/test/unittests/heap/heap-utils.h @@ -65,7 +65,7 @@ class WithHeapInternals : public TMixin, HeapInternalsBase { } void GrowNewSpace() { - SafepointScope scope(heap()); + IsolateSafepointScope scope(heap()); if (!heap()->new_space()->IsAtMaximumCapacity()) { heap()->new_space()->Grow(); } @@ -89,7 +89,7 @@ class WithHeapInternals : public TMixin, HeapInternalsBase { void GcAndSweep(i::AllocationSpace space) { heap()->CollectGarbage(space, GarbageCollectionReason::kTesting); if (heap()->sweeping_in_progress()) { - SafepointScope scope(heap()); + IsolateSafepointScope scope(heap()); heap()->EnsureSweepingCompleted( Heap::SweepingForcedFinalizationMode::kV8Only); } diff --git a/test/unittests/heap/marking-inner-pointer-resolution-unittest.cc b/test/unittests/heap/marking-inner-pointer-resolution-unittest.cc index 1dd205574f..6801f1441f 100644 --- a/test/unittests/heap/marking-inner-pointer-resolution-unittest.cc +++ b/test/unittests/heap/marking-inner-pointer-resolution-unittest.cc @@ -680,7 +680,7 @@ TEST_F(InnerPointerResolutionHeapTest, UnusedRegularYoungPages) { // Start incremental marking and mark the third object. i::IncrementalMarking* marking = heap()->incremental_marking(); if (marking->IsStopped()) { - SafepointScope scope(heap()); + IsolateSafepointScope scope(heap()); heap()->tracer()->StartCycle( GarbageCollector::MARK_COMPACTOR, GarbageCollectionReason::kTesting, "unit test", GCTracer::MarkingType::kIncremental); diff --git a/test/unittests/heap/safepoint-unittest.cc b/test/unittests/heap/safepoint-unittest.cc index d7bfdda2cd..8115085a38 100644 --- a/test/unittests/heap/safepoint-unittest.cc +++ b/test/unittests/heap/safepoint-unittest.cc @@ -21,7 +21,7 @@ TEST_F(SafepointTest, ReachSafepointWithoutLocalHeaps) { Heap* heap = i_isolate()->heap(); bool run = false; { - SafepointScope scope(heap); + IsolateSafepointScope scope(heap); run = true; } CHECK(run); @@ -68,7 +68,7 @@ TEST_F(SafepointTest, StopParkedThreads) { } { - SafepointScope scope(heap); + IsolateSafepointScope scope(heap); safepoints++; } mutex.Unlock(); @@ -124,7 +124,7 @@ TEST_F(SafepointTest, StopRunningThreads) { } for (int i = 0; i < kSafepoints; i++) { - SafepointScope scope(heap); + IsolateSafepointScope scope(heap); safepoint_count++; }