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

[heap] Rename Safepoint to GlobalSafepoint

Avoid name clash with Safepoint in src/codgen and use renaming to
emphasize that class reaches a safepoint in each background thread.

Bug: v8:10315
Change-Id: I391cdcfaf533a0fe0d5923207234eb2a8411eb93
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2139576Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67037}
parent 09b0aae8
......@@ -202,7 +202,7 @@ Heap::Heap()
: isolate_(isolate()),
memory_pressure_level_(MemoryPressureLevel::kNone),
global_pretenuring_feedback_(kInitialFeedbackCapacity),
safepoint_(new Safepoint(this)),
safepoint_(new GlobalSafepoint(this)),
external_string_table_(this) {
// Ensure old_generation_size_ is a multiple of kPageSize.
DCHECK_EQ(0, max_old_generation_size_ & (Page::kPageSize - 1));
......
......@@ -66,6 +66,7 @@ class ConcurrentMarking;
class GCIdleTimeHandler;
class GCIdleTimeHeapState;
class GCTracer;
class GlobalSafepoint;
class HeapObjectAllocationTracker;
class HeapObjectsFilter;
class HeapStats;
......@@ -83,7 +84,6 @@ class Page;
class PagedSpace;
class ReadOnlyHeap;
class RootVisitor;
class Safepoint;
class ScavengeJob;
class Scavenger;
class ScavengerCollector;
......@@ -620,7 +620,7 @@ class Heap {
void AppendArrayBufferExtension(JSArrayBuffer object,
ArrayBufferExtension* extension);
Safepoint* safepoint() { return safepoint_.get(); }
GlobalSafepoint* safepoint() { return safepoint_.get(); }
V8_EXPORT_PRIVATE double MonotonicallyIncreasingTimeInMs();
......@@ -2166,7 +2166,7 @@ class Heap {
GCCallbackFlags current_gc_callback_flags_ =
GCCallbackFlags::kNoGCCallbackFlags;
std::unique_ptr<Safepoint> safepoint_;
std::unique_ptr<GlobalSafepoint> safepoint_;
bool is_current_gc_forced_ = false;
......
......@@ -11,6 +11,7 @@
#include "src/base/platform/condition-variable.h"
#include "src/base/platform/mutex.h"
#include "src/execution/isolate.h"
#include "src/heap/safepoint.h"
namespace v8 {
namespace internal {
......@@ -78,7 +79,7 @@ class LocalHeap {
std::unique_ptr<PersistentHandles> persistent_handles_;
friend class Heap;
friend class Safepoint;
friend class GlobalSafepoint;
friend class ParkedScope;
};
......
......@@ -12,14 +12,14 @@
namespace v8 {
namespace internal {
Safepoint::Safepoint(Heap* heap)
GlobalSafepoint::GlobalSafepoint(Heap* heap)
: heap_(heap), local_heaps_head_(nullptr), is_active_(false) {}
void Safepoint::Start() { StopThreads(); }
void GlobalSafepoint::Start() { StopThreads(); }
void Safepoint::End() { ResumeThreads(); }
void GlobalSafepoint::End() { ResumeThreads(); }
void Safepoint::StopThreads() {
void GlobalSafepoint::StopThreads() {
local_heaps_mutex_.Lock();
barrier_.Arm();
......@@ -41,7 +41,7 @@ void Safepoint::StopThreads() {
is_active_ = true;
}
void Safepoint::ResumeThreads() {
void GlobalSafepoint::ResumeThreads() {
is_active_ = false;
for (LocalHeap* current = local_heaps_head_; current;
......@@ -54,7 +54,7 @@ void Safepoint::ResumeThreads() {
local_heaps_mutex_.Unlock();
}
void Safepoint::EnterFromThread(LocalHeap* local_heap) {
void GlobalSafepoint::EnterFromThread(LocalHeap* local_heap) {
{
base::MutexGuard guard(&local_heap->state_mutex_);
local_heap->state_ = LocalHeap::ThreadState::Safepoint;
......@@ -69,20 +69,20 @@ void Safepoint::EnterFromThread(LocalHeap* local_heap) {
}
}
void Safepoint::Barrier::Arm() {
void GlobalSafepoint::Barrier::Arm() {
base::MutexGuard guard(&mutex_);
CHECK(!armed_);
armed_ = true;
}
void Safepoint::Barrier::Disarm() {
void GlobalSafepoint::Barrier::Disarm() {
base::MutexGuard guard(&mutex_);
CHECK(armed_);
armed_ = false;
cond_.NotifyAll();
}
void Safepoint::Barrier::Wait() {
void GlobalSafepoint::Barrier::Wait() {
base::MutexGuard guard(&mutex_);
while (armed_) {
cond_.Wait(&mutex_);
......@@ -95,7 +95,7 @@ SafepointScope::SafepointScope(Heap* heap) : safepoint_(heap->safepoint()) {
SafepointScope::~SafepointScope() { safepoint_->ResumeThreads(); }
void Safepoint::AddLocalHeap(LocalHeap* local_heap) {
void GlobalSafepoint::AddLocalHeap(LocalHeap* local_heap) {
base::MutexGuard guard(&local_heaps_mutex_);
if (local_heaps_head_) local_heaps_head_->prev_ = local_heap;
local_heap->prev_ = nullptr;
......@@ -103,7 +103,7 @@ void Safepoint::AddLocalHeap(LocalHeap* local_heap) {
local_heaps_head_ = local_heap;
}
void Safepoint::RemoveLocalHeap(LocalHeap* local_heap) {
void GlobalSafepoint::RemoveLocalHeap(LocalHeap* local_heap) {
base::MutexGuard guard(&local_heaps_mutex_);
if (local_heap->next_) local_heap->next_->prev_ = local_heap->prev_;
if (local_heap->prev_)
......@@ -112,7 +112,7 @@ void Safepoint::RemoveLocalHeap(LocalHeap* local_heap) {
local_heaps_head_ = local_heap->next_;
}
bool Safepoint::ContainsLocalHeap(LocalHeap* local_heap) {
bool GlobalSafepoint::ContainsLocalHeap(LocalHeap* local_heap) {
base::MutexGuard guard(&local_heaps_mutex_);
LocalHeap* current = local_heaps_head_;
......@@ -124,12 +124,12 @@ bool Safepoint::ContainsLocalHeap(LocalHeap* local_heap) {
return false;
}
bool Safepoint::ContainsAnyLocalHeap() {
bool GlobalSafepoint::ContainsAnyLocalHeap() {
base::MutexGuard guard(&local_heaps_mutex_);
return local_heaps_head_ != nullptr;
}
void Safepoint::Iterate(RootVisitor* visitor) {
void GlobalSafepoint::Iterate(RootVisitor* visitor) {
DCHECK(IsActive());
for (LocalHeap* current = local_heaps_head_; current;
current = current->next_) {
......
......@@ -17,9 +17,11 @@ class Heap;
class LocalHeap;
class RootVisitor;
class Safepoint {
// Used to bring all background threads with heap access to a safepoint such
// that e.g. a garabge collection can be performed.
class GlobalSafepoint {
public:
explicit Safepoint(Heap* heap);
explicit GlobalSafepoint(Heap* heap);
// Enter the safepoint from a thread
void EnterFromThread(LocalHeap* local_heap);
......@@ -75,7 +77,7 @@ class SafepointScope {
V8_EXPORT_PRIVATE ~SafepointScope();
private:
Safepoint* safepoint_;
GlobalSafepoint* 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