[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/+/2139576 Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Commit-Queue: Dominik Inführ <dinfuehr@chromium.org> Cr-Commit-Position: refs/heads/master@{#67037}
This commit is contained in:
parent
09b0aae81c
commit
12fae1459f
@ -202,7 +202,7 @@ Heap::Heap()
|
|||||||
: isolate_(isolate()),
|
: isolate_(isolate()),
|
||||||
memory_pressure_level_(MemoryPressureLevel::kNone),
|
memory_pressure_level_(MemoryPressureLevel::kNone),
|
||||||
global_pretenuring_feedback_(kInitialFeedbackCapacity),
|
global_pretenuring_feedback_(kInitialFeedbackCapacity),
|
||||||
safepoint_(new Safepoint(this)),
|
safepoint_(new GlobalSafepoint(this)),
|
||||||
external_string_table_(this) {
|
external_string_table_(this) {
|
||||||
// Ensure old_generation_size_ is a multiple of kPageSize.
|
// Ensure old_generation_size_ is a multiple of kPageSize.
|
||||||
DCHECK_EQ(0, max_old_generation_size_ & (Page::kPageSize - 1));
|
DCHECK_EQ(0, max_old_generation_size_ & (Page::kPageSize - 1));
|
||||||
|
@ -66,6 +66,7 @@ class ConcurrentMarking;
|
|||||||
class GCIdleTimeHandler;
|
class GCIdleTimeHandler;
|
||||||
class GCIdleTimeHeapState;
|
class GCIdleTimeHeapState;
|
||||||
class GCTracer;
|
class GCTracer;
|
||||||
|
class GlobalSafepoint;
|
||||||
class HeapObjectAllocationTracker;
|
class HeapObjectAllocationTracker;
|
||||||
class HeapObjectsFilter;
|
class HeapObjectsFilter;
|
||||||
class HeapStats;
|
class HeapStats;
|
||||||
@ -83,7 +84,6 @@ class Page;
|
|||||||
class PagedSpace;
|
class PagedSpace;
|
||||||
class ReadOnlyHeap;
|
class ReadOnlyHeap;
|
||||||
class RootVisitor;
|
class RootVisitor;
|
||||||
class Safepoint;
|
|
||||||
class ScavengeJob;
|
class ScavengeJob;
|
||||||
class Scavenger;
|
class Scavenger;
|
||||||
class ScavengerCollector;
|
class ScavengerCollector;
|
||||||
@ -620,7 +620,7 @@ class Heap {
|
|||||||
void AppendArrayBufferExtension(JSArrayBuffer object,
|
void AppendArrayBufferExtension(JSArrayBuffer object,
|
||||||
ArrayBufferExtension* extension);
|
ArrayBufferExtension* extension);
|
||||||
|
|
||||||
Safepoint* safepoint() { return safepoint_.get(); }
|
GlobalSafepoint* safepoint() { return safepoint_.get(); }
|
||||||
|
|
||||||
V8_EXPORT_PRIVATE double MonotonicallyIncreasingTimeInMs();
|
V8_EXPORT_PRIVATE double MonotonicallyIncreasingTimeInMs();
|
||||||
|
|
||||||
@ -2166,7 +2166,7 @@ class Heap {
|
|||||||
GCCallbackFlags current_gc_callback_flags_ =
|
GCCallbackFlags current_gc_callback_flags_ =
|
||||||
GCCallbackFlags::kNoGCCallbackFlags;
|
GCCallbackFlags::kNoGCCallbackFlags;
|
||||||
|
|
||||||
std::unique_ptr<Safepoint> safepoint_;
|
std::unique_ptr<GlobalSafepoint> safepoint_;
|
||||||
|
|
||||||
bool is_current_gc_forced_ = false;
|
bool is_current_gc_forced_ = false;
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "src/base/platform/condition-variable.h"
|
#include "src/base/platform/condition-variable.h"
|
||||||
#include "src/base/platform/mutex.h"
|
#include "src/base/platform/mutex.h"
|
||||||
#include "src/execution/isolate.h"
|
#include "src/execution/isolate.h"
|
||||||
|
#include "src/heap/safepoint.h"
|
||||||
|
|
||||||
namespace v8 {
|
namespace v8 {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
@ -78,7 +79,7 @@ class LocalHeap {
|
|||||||
std::unique_ptr<PersistentHandles> persistent_handles_;
|
std::unique_ptr<PersistentHandles> persistent_handles_;
|
||||||
|
|
||||||
friend class Heap;
|
friend class Heap;
|
||||||
friend class Safepoint;
|
friend class GlobalSafepoint;
|
||||||
friend class ParkedScope;
|
friend class ParkedScope;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,14 +12,14 @@
|
|||||||
namespace v8 {
|
namespace v8 {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
Safepoint::Safepoint(Heap* heap)
|
GlobalSafepoint::GlobalSafepoint(Heap* heap)
|
||||||
: heap_(heap), local_heaps_head_(nullptr), is_active_(false) {}
|
: 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();
|
local_heaps_mutex_.Lock();
|
||||||
|
|
||||||
barrier_.Arm();
|
barrier_.Arm();
|
||||||
@ -41,7 +41,7 @@ void Safepoint::StopThreads() {
|
|||||||
is_active_ = true;
|
is_active_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Safepoint::ResumeThreads() {
|
void GlobalSafepoint::ResumeThreads() {
|
||||||
is_active_ = false;
|
is_active_ = false;
|
||||||
|
|
||||||
for (LocalHeap* current = local_heaps_head_; current;
|
for (LocalHeap* current = local_heaps_head_; current;
|
||||||
@ -54,7 +54,7 @@ void Safepoint::ResumeThreads() {
|
|||||||
local_heaps_mutex_.Unlock();
|
local_heaps_mutex_.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Safepoint::EnterFromThread(LocalHeap* local_heap) {
|
void GlobalSafepoint::EnterFromThread(LocalHeap* local_heap) {
|
||||||
{
|
{
|
||||||
base::MutexGuard guard(&local_heap->state_mutex_);
|
base::MutexGuard guard(&local_heap->state_mutex_);
|
||||||
local_heap->state_ = LocalHeap::ThreadState::Safepoint;
|
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_);
|
base::MutexGuard guard(&mutex_);
|
||||||
CHECK(!armed_);
|
CHECK(!armed_);
|
||||||
armed_ = true;
|
armed_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Safepoint::Barrier::Disarm() {
|
void GlobalSafepoint::Barrier::Disarm() {
|
||||||
base::MutexGuard guard(&mutex_);
|
base::MutexGuard guard(&mutex_);
|
||||||
CHECK(armed_);
|
CHECK(armed_);
|
||||||
armed_ = false;
|
armed_ = false;
|
||||||
cond_.NotifyAll();
|
cond_.NotifyAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Safepoint::Barrier::Wait() {
|
void GlobalSafepoint::Barrier::Wait() {
|
||||||
base::MutexGuard guard(&mutex_);
|
base::MutexGuard guard(&mutex_);
|
||||||
while (armed_) {
|
while (armed_) {
|
||||||
cond_.Wait(&mutex_);
|
cond_.Wait(&mutex_);
|
||||||
@ -95,7 +95,7 @@ SafepointScope::SafepointScope(Heap* heap) : safepoint_(heap->safepoint()) {
|
|||||||
|
|
||||||
SafepointScope::~SafepointScope() { safepoint_->ResumeThreads(); }
|
SafepointScope::~SafepointScope() { safepoint_->ResumeThreads(); }
|
||||||
|
|
||||||
void Safepoint::AddLocalHeap(LocalHeap* local_heap) {
|
void GlobalSafepoint::AddLocalHeap(LocalHeap* local_heap) {
|
||||||
base::MutexGuard guard(&local_heaps_mutex_);
|
base::MutexGuard guard(&local_heaps_mutex_);
|
||||||
if (local_heaps_head_) local_heaps_head_->prev_ = local_heap;
|
if (local_heaps_head_) local_heaps_head_->prev_ = local_heap;
|
||||||
local_heap->prev_ = nullptr;
|
local_heap->prev_ = nullptr;
|
||||||
@ -103,7 +103,7 @@ void Safepoint::AddLocalHeap(LocalHeap* local_heap) {
|
|||||||
local_heaps_head_ = 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_);
|
base::MutexGuard guard(&local_heaps_mutex_);
|
||||||
if (local_heap->next_) local_heap->next_->prev_ = local_heap->prev_;
|
if (local_heap->next_) local_heap->next_->prev_ = local_heap->prev_;
|
||||||
if (local_heap->prev_)
|
if (local_heap->prev_)
|
||||||
@ -112,7 +112,7 @@ void Safepoint::RemoveLocalHeap(LocalHeap* local_heap) {
|
|||||||
local_heaps_head_ = local_heap->next_;
|
local_heaps_head_ = local_heap->next_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Safepoint::ContainsLocalHeap(LocalHeap* local_heap) {
|
bool GlobalSafepoint::ContainsLocalHeap(LocalHeap* local_heap) {
|
||||||
base::MutexGuard guard(&local_heaps_mutex_);
|
base::MutexGuard guard(&local_heaps_mutex_);
|
||||||
LocalHeap* current = local_heaps_head_;
|
LocalHeap* current = local_heaps_head_;
|
||||||
|
|
||||||
@ -124,12 +124,12 @@ bool Safepoint::ContainsLocalHeap(LocalHeap* local_heap) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Safepoint::ContainsAnyLocalHeap() {
|
bool GlobalSafepoint::ContainsAnyLocalHeap() {
|
||||||
base::MutexGuard guard(&local_heaps_mutex_);
|
base::MutexGuard guard(&local_heaps_mutex_);
|
||||||
return local_heaps_head_ != nullptr;
|
return local_heaps_head_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Safepoint::Iterate(RootVisitor* visitor) {
|
void GlobalSafepoint::Iterate(RootVisitor* visitor) {
|
||||||
DCHECK(IsActive());
|
DCHECK(IsActive());
|
||||||
for (LocalHeap* current = local_heaps_head_; current;
|
for (LocalHeap* current = local_heaps_head_; current;
|
||||||
current = current->next_) {
|
current = current->next_) {
|
||||||
|
@ -17,9 +17,11 @@ class Heap;
|
|||||||
class LocalHeap;
|
class LocalHeap;
|
||||||
class RootVisitor;
|
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:
|
public:
|
||||||
explicit Safepoint(Heap* heap);
|
explicit GlobalSafepoint(Heap* heap);
|
||||||
|
|
||||||
// Enter the safepoint from a thread
|
// Enter the safepoint from a thread
|
||||||
void EnterFromThread(LocalHeap* local_heap);
|
void EnterFromThread(LocalHeap* local_heap);
|
||||||
@ -75,7 +77,7 @@ class SafepointScope {
|
|||||||
V8_EXPORT_PRIVATE ~SafepointScope();
|
V8_EXPORT_PRIVATE ~SafepointScope();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Safepoint* safepoint_;
|
GlobalSafepoint* safepoint_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
Loading…
Reference in New Issue
Block a user