Commit 8659c9c3 authored by Dominik Inführ's avatar Dominik Inführ Committed by V8 LUCI CQ

[heap] Rename GlobalSafepoint to IsolateSafepoint

We are going to introduce safepoints across multiple isolates, with
this the name GlobalSafepoint might be misleading. Use IsolateSafepoint
as name to emphasise this class reaches a safepoint for a single
isolate only.

No functional changes.

Bug: v8:11708
Change-Id: I8254031dd0bc8e6dcf9f7353297803c37dba47ed
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3207901
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77268}
parent d4ac75e8
......@@ -213,7 +213,7 @@ Heap::Heap()
: isolate_(isolate()),
memory_pressure_level_(MemoryPressureLevel::kNone),
global_pretenuring_feedback_(kInitialFeedbackCapacity),
safepoint_(new GlobalSafepoint(this)),
safepoint_(std::make_unique<IsolateSafepoint>(this)),
external_string_table_(this),
collection_barrier_(new CollectionBarrier(this)) {
// Ensure old_generation_size_ is a multiple of kPageSize.
......@@ -2297,9 +2297,9 @@ void Heap::PerformSharedGarbageCollection(Isolate* initiator,
DCHECK_NOT_NULL(client->shared_isolate());
Heap* client_heap = client->heap();
GlobalSafepoint::StopMainThread stop_main_thread =
initiator == client ? GlobalSafepoint::StopMainThread::kNo
: GlobalSafepoint::StopMainThread::kYes;
IsolateSafepoint::StopMainThread stop_main_thread =
initiator == client ? IsolateSafepoint::StopMainThread::kNo
: IsolateSafepoint::StopMainThread::kYes;
client_heap->safepoint()->EnterSafepointScope(stop_main_thread);
......@@ -2310,9 +2310,9 @@ void Heap::PerformSharedGarbageCollection(Isolate* initiator,
PerformGarbageCollection(GarbageCollector::MARK_COMPACTOR);
isolate()->IterateClientIsolates([initiator](Isolate* client) {
GlobalSafepoint::StopMainThread stop_main_thread =
initiator == client ? GlobalSafepoint::StopMainThread::kNo
: GlobalSafepoint::StopMainThread::kYes;
IsolateSafepoint::StopMainThread stop_main_thread =
initiator == client ? IsolateSafepoint::StopMainThread::kNo
: IsolateSafepoint::StopMainThread::kYes;
client->heap()->safepoint()->LeaveSafepointScope(stop_main_thread);
});
......
......@@ -80,7 +80,7 @@ class GCIdleTimeHeapState;
class GCTracer;
template <typename T>
class GlobalHandleVector;
class GlobalSafepoint;
class IsolateSafepoint;
class HeapObjectAllocationTracker;
class HeapObjectsFilter;
class HeapStats;
......@@ -735,7 +735,7 @@ class Heap {
void DetachArrayBufferExtension(JSArrayBuffer object,
ArrayBufferExtension* extension);
GlobalSafepoint* safepoint() { return safepoint_.get(); }
IsolateSafepoint* safepoint() { return safepoint_.get(); }
V8_EXPORT_PRIVATE double MonotonicallyIncreasingTimeInMs() const;
......@@ -2455,7 +2455,7 @@ class Heap {
GCCallbackFlags current_gc_callback_flags_ =
GCCallbackFlags::kNoGCCallbackFlags;
std::unique_ptr<GlobalSafepoint> safepoint_;
std::unique_ptr<IsolateSafepoint> safepoint_;
bool is_current_gc_forced_ = false;
bool is_current_gc_for_heap_profiler_ = false;
......
......@@ -191,7 +191,7 @@ void LocalHeap::SafepointSlowPath() {
ThreadState expected = kSafepointRequested;
CHECK(state_.compare_exchange_strong(expected, kSafepoint));
heap_->safepoint()->WaitInSafepoint();
// This might be a bit surprising, GlobalSafepoint transitions the state
// This might be a bit surprising, IsolateSafepoint transitions the state
// from Safepoint (--> Running) --> Parked when returning from the
// safepoint.
Unpark();
......
......@@ -225,7 +225,7 @@ 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 ParkedScope;
......
......@@ -19,10 +19,10 @@
namespace v8 {
namespace internal {
GlobalSafepoint::GlobalSafepoint(Heap* heap)
IsolateSafepoint::IsolateSafepoint(Heap* heap)
: heap_(heap), local_heaps_head_(nullptr), active_safepoint_scopes_(0) {}
void GlobalSafepoint::EnterSafepointScope(StopMainThread stop_main_thread) {
void IsolateSafepoint::EnterSafepointScope(StopMainThread stop_main_thread) {
// Safepoints need to be initiated on the main thread.
DCHECK_EQ(ThreadId::Current(), heap_->isolate()->thread_id());
DCHECK_NULL(LocalHeap::Current());
......@@ -68,7 +68,7 @@ void GlobalSafepoint::EnterSafepointScope(StopMainThread stop_main_thread) {
barrier_.WaitUntilRunningThreadsInSafepoint(running);
}
void GlobalSafepoint::LeaveSafepointScope(StopMainThread stop_main_thread) {
void IsolateSafepoint::LeaveSafepointScope(StopMainThread stop_main_thread) {
// Safepoints need to be initiated on the main thread.
DCHECK_EQ(ThreadId::Current(), heap_->isolate()->thread_id());
DCHECK_NULL(LocalHeap::Current());
......@@ -101,20 +101,20 @@ void GlobalSafepoint::LeaveSafepointScope(StopMainThread stop_main_thread) {
local_heaps_mutex_.Unlock();
}
void GlobalSafepoint::WaitInSafepoint() { barrier_.WaitInSafepoint(); }
void IsolateSafepoint::WaitInSafepoint() { barrier_.WaitInSafepoint(); }
void GlobalSafepoint::WaitInUnpark() { barrier_.WaitInUnpark(); }
void IsolateSafepoint::WaitInUnpark() { barrier_.WaitInUnpark(); }
void GlobalSafepoint::NotifyPark() { barrier_.NotifyPark(); }
void IsolateSafepoint::NotifyPark() { barrier_.NotifyPark(); }
void GlobalSafepoint::Barrier::Arm() {
void IsolateSafepoint::Barrier::Arm() {
base::MutexGuard guard(&mutex_);
DCHECK(!IsArmed());
armed_ = true;
stopped_ = 0;
}
void GlobalSafepoint::Barrier::Disarm() {
void IsolateSafepoint::Barrier::Disarm() {
base::MutexGuard guard(&mutex_);
DCHECK(IsArmed());
armed_ = false;
......@@ -122,7 +122,8 @@ void GlobalSafepoint::Barrier::Disarm() {
cv_resume_.NotifyAll();
}
void GlobalSafepoint::Barrier::WaitUntilRunningThreadsInSafepoint(int running) {
void IsolateSafepoint::Barrier::WaitUntilRunningThreadsInSafepoint(
int running) {
base::MutexGuard guard(&mutex_);
DCHECK(IsArmed());
while (stopped_ < running) {
......@@ -131,14 +132,14 @@ void GlobalSafepoint::Barrier::WaitUntilRunningThreadsInSafepoint(int running) {
DCHECK_EQ(stopped_, running);
}
void GlobalSafepoint::Barrier::NotifyPark() {
void IsolateSafepoint::Barrier::NotifyPark() {
base::MutexGuard guard(&mutex_);
CHECK(IsArmed());
stopped_++;
cv_stopped_.NotifyOne();
}
void GlobalSafepoint::Barrier::WaitInSafepoint() {
void IsolateSafepoint::Barrier::WaitInSafepoint() {
base::MutexGuard guard(&mutex_);
CHECK(IsArmed());
stopped_++;
......@@ -149,7 +150,7 @@ void GlobalSafepoint::Barrier::WaitInSafepoint() {
}
}
void GlobalSafepoint::Barrier::WaitInUnpark() {
void IsolateSafepoint::Barrier::WaitInUnpark() {
base::MutexGuard guard(&mutex_);
while (IsArmed()) {
......@@ -158,14 +159,14 @@ void GlobalSafepoint::Barrier::WaitInUnpark() {
}
SafepointScope::SafepointScope(Heap* heap) : safepoint_(heap->safepoint()) {
safepoint_->EnterSafepointScope(GlobalSafepoint::StopMainThread::kNo);
safepoint_->EnterSafepointScope(IsolateSafepoint::StopMainThread::kNo);
}
SafepointScope::~SafepointScope() {
safepoint_->LeaveSafepointScope(GlobalSafepoint::StopMainThread::kNo);
safepoint_->LeaveSafepointScope(IsolateSafepoint::StopMainThread::kNo);
}
bool GlobalSafepoint::ContainsLocalHeap(LocalHeap* local_heap) {
bool IsolateSafepoint::ContainsLocalHeap(LocalHeap* local_heap) {
base::MutexGuard guard(&local_heaps_mutex_);
LocalHeap* current = local_heaps_head_;
......@@ -177,12 +178,12 @@ bool GlobalSafepoint::ContainsLocalHeap(LocalHeap* local_heap) {
return false;
}
bool GlobalSafepoint::ContainsAnyLocalHeap() {
bool IsolateSafepoint::ContainsAnyLocalHeap() {
base::MutexGuard guard(&local_heaps_mutex_);
return local_heaps_head_ != nullptr;
}
void GlobalSafepoint::Iterate(RootVisitor* visitor) {
void IsolateSafepoint::Iterate(RootVisitor* visitor) {
DCHECK(IsActive());
for (LocalHeap* current = local_heaps_head_; current;
current = current->next_) {
......
......@@ -20,9 +20,9 @@ class RootVisitor;
// Used to bring all threads with heap access to a safepoint such that e.g. a
// garbage collection can be performed.
class GlobalSafepoint {
class IsolateSafepoint final {
public:
explicit GlobalSafepoint(Heap* heap);
explicit IsolateSafepoint(Heap* heap);
// Wait until unpark operation is safe again
void WaitInUnpark();
......@@ -130,7 +130,7 @@ class V8_NODISCARD SafepointScope {
V8_EXPORT_PRIVATE ~SafepointScope();
private:
GlobalSafepoint* safepoint_;
IsolateSafepoint* safepoint_;
};
} // namespace internal
......
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