[heap] Rename safepoint scopes
This CL simplifies safepoint scopes, there are now three kinds of safepoint scopes: 1) IsolateSafepointScope - performs an isolate local safepoint 2) GlobalSafepointScope - a global safepoint across multiple isolates 3) SafepointScope - chooses based on condition between local/global This CL is not supposed to change current safepointing behavior in any way. The CL renames the current SafepointScope to IsolateSafepointScope and changes GlobalSafepointScope to always perform a global safepoint. It then also introduces the new SafepointScope and makes use of it for snapshotting and in heap.cc. Bug: v8:13267 Change-Id: Ie7e1f81b6158c98d3d98552ba735cc73c9b869c5 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3973310 Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Commit-Queue: Dominik Inführ <dinfuehr@chromium.org> Cr-Commit-Position: refs/heads/main@{#83912}
This commit is contained in:
parent
6cd8c58097
commit
34d6823f8b
@ -617,7 +617,10 @@ StartupData SnapshotCreator::CreateBlob(
|
|||||||
i::Snapshot::ClearReconstructableDataForSerialization(
|
i::Snapshot::ClearReconstructableDataForSerialization(
|
||||||
i_isolate, function_code_handling == FunctionCodeHandling::kClear);
|
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;
|
i::DisallowGarbageCollection no_gc_from_here_on;
|
||||||
|
|
||||||
// Create a vector with all contexts and clear associated Persistent fields.
|
// Create a vector with all contexts and clear associated Persistent fields.
|
||||||
@ -655,7 +658,7 @@ StartupData SnapshotCreator::CreateBlob(
|
|||||||
|
|
||||||
data->created_ = true;
|
data->created_ = true;
|
||||||
return i::Snapshot::Create(i_isolate, &contexts, embedder_fields_serializers,
|
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 {
|
bool StartupData::CanBeRehashed() const {
|
||||||
|
@ -26,7 +26,7 @@ class V8_EXPORT_PRIVATE CombinedHeapObjectIterator final {
|
|||||||
HeapObject Next();
|
HeapObject Next();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SafepointScope safepoint_scope_;
|
IsolateSafepointScope safepoint_scope_;
|
||||||
HeapObjectIterator heap_iterator_;
|
HeapObjectIterator heap_iterator_;
|
||||||
ReadOnlyHeapObjectIterator ro_heap_iterator_;
|
ReadOnlyHeapObjectIterator ro_heap_iterator_;
|
||||||
};
|
};
|
||||||
|
@ -73,7 +73,7 @@ void HeapVerification::Verify() {
|
|||||||
CHECK(heap()->HasBeenSetUp());
|
CHECK(heap()->HasBeenSetUp());
|
||||||
AllowGarbageCollection allow_gc;
|
AllowGarbageCollection allow_gc;
|
||||||
IgnoreLocalGCRequests ignore_gc_requests(heap());
|
IgnoreLocalGCRequests ignore_gc_requests(heap());
|
||||||
SafepointScope safepoint_scope(heap());
|
IsolateSafepointScope safepoint_scope(heap());
|
||||||
HandleScope scope(isolate());
|
HandleScope scope(isolate());
|
||||||
|
|
||||||
heap()->MakeHeapIterable();
|
heap()->MakeHeapIterable();
|
||||||
|
@ -1841,18 +1841,16 @@ void Heap::StartIncrementalMarking(int gc_flags,
|
|||||||
CompleteSweepingFull();
|
CompleteSweepingFull();
|
||||||
}
|
}
|
||||||
|
|
||||||
base::Optional<GlobalSafepointScope> global_safepoint_scope;
|
|
||||||
base::Optional<SafepointScope> safepoint_scope;
|
base::Optional<SafepointScope> safepoint_scope;
|
||||||
|
|
||||||
{
|
{
|
||||||
AllowGarbageCollection allow_shared_gc;
|
AllowGarbageCollection allow_shared_gc;
|
||||||
IgnoreLocalGCRequests ignore_gc_requests(this);
|
IgnoreLocalGCRequests ignore_gc_requests(this);
|
||||||
|
|
||||||
if (isolate()->is_shared_heap_isolate()) {
|
SafepointKind safepoint_kind = isolate()->is_shared_heap_isolate()
|
||||||
global_safepoint_scope.emplace(isolate());
|
? SafepointKind::kGlobal
|
||||||
} else {
|
: SafepointKind::kIsolate;
|
||||||
safepoint_scope.emplace(this);
|
safepoint_scope.emplace(isolate(), safepoint_kind);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -2165,18 +2163,17 @@ size_t Heap::PerformGarbageCollection(
|
|||||||
DCHECK(tracer()->IsConsistentWithCollector(collector));
|
DCHECK(tracer()->IsConsistentWithCollector(collector));
|
||||||
TRACE_GC_EPOCH(tracer(), CollectorScopeId(collector), ThreadKind::kMain);
|
TRACE_GC_EPOCH(tracer(), CollectorScopeId(collector), ThreadKind::kMain);
|
||||||
|
|
||||||
base::Optional<GlobalSafepointScope> global_safepoint_scope;
|
base::Optional<SafepointScope> safepoint_scope;
|
||||||
base::Optional<SafepointScope> isolate_safepoint_scope;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
AllowGarbageCollection allow_shared_gc;
|
AllowGarbageCollection allow_shared_gc;
|
||||||
IgnoreLocalGCRequests ignore_gc_requests(this);
|
IgnoreLocalGCRequests ignore_gc_requests(this);
|
||||||
|
|
||||||
if (isolate()->is_shared_heap_isolate()) {
|
SafepointKind safepoint_kind =
|
||||||
global_safepoint_scope.emplace(isolate());
|
v8_flags.shared_space && isolate()->is_shared_heap_isolate()
|
||||||
} else {
|
? SafepointKind::kGlobal
|
||||||
isolate_safepoint_scope.emplace(this);
|
: SafepointKind::kIsolate;
|
||||||
}
|
safepoint_scope.emplace(isolate(), safepoint_kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
collection_barrier_->StopTimeToCollectionTimer();
|
collection_barrier_->StopTimeToCollectionTimer();
|
||||||
@ -3433,7 +3430,7 @@ FixedArrayBase Heap::LeftTrimFixedArray(FixedArrayBase object,
|
|||||||
if (v8_flags.enable_slow_asserts) {
|
if (v8_flags.enable_slow_asserts) {
|
||||||
// Make sure the stack or other roots (e.g., Handles) don't contain pointers
|
// Make sure the stack or other roots (e.g., Handles) don't contain pointers
|
||||||
// to the original FixedArray (which is now the filler object).
|
// to the original FixedArray (which is now the filler object).
|
||||||
base::Optional<SafepointScope> safepoint_scope;
|
base::Optional<IsolateSafepointScope> safepoint_scope;
|
||||||
|
|
||||||
{
|
{
|
||||||
AllowGarbageCollection allow_gc;
|
AllowGarbageCollection allow_gc;
|
||||||
@ -4201,7 +4198,7 @@ std::unique_ptr<v8::MeasureMemoryDelegate> Heap::MeasureMemoryDelegate(
|
|||||||
void Heap::CollectCodeStatistics() {
|
void Heap::CollectCodeStatistics() {
|
||||||
TRACE_EVENT0("v8", "Heap::CollectCodeStatistics");
|
TRACE_EVENT0("v8", "Heap::CollectCodeStatistics");
|
||||||
IgnoreLocalGCRequests ignore_gc_requests(this);
|
IgnoreLocalGCRequests ignore_gc_requests(this);
|
||||||
SafepointScope safepoint_scope(this);
|
IsolateSafepointScope safepoint_scope(this);
|
||||||
MakeHeapIterable();
|
MakeHeapIterable();
|
||||||
CodeStatistics::ResetCodeAndMetadataStatistics(isolate());
|
CodeStatistics::ResetCodeAndMetadataStatistics(isolate());
|
||||||
// We do not look for code in new space, or map space. If code
|
// We do not look for code in new space, or map space. If code
|
||||||
@ -6401,7 +6398,7 @@ class UnreachableObjectsFilter : public HeapObjectsFilter {
|
|||||||
HeapObjectIterator::HeapObjectIterator(
|
HeapObjectIterator::HeapObjectIterator(
|
||||||
Heap* heap, HeapObjectIterator::HeapObjectsFiltering filtering)
|
Heap* heap, HeapObjectIterator::HeapObjectsFiltering filtering)
|
||||||
: heap_(heap),
|
: heap_(heap),
|
||||||
safepoint_scope_(std::make_unique<SafepointScope>(heap)),
|
safepoint_scope_(std::make_unique<IsolateSafepointScope>(heap)),
|
||||||
filtering_(filtering),
|
filtering_(filtering),
|
||||||
filter_(nullptr),
|
filter_(nullptr),
|
||||||
space_iterator_(nullptr),
|
space_iterator_(nullptr),
|
||||||
|
@ -105,6 +105,7 @@ class HeapObjectAllocationTracker;
|
|||||||
class HeapObjectsFilter;
|
class HeapObjectsFilter;
|
||||||
class HeapStats;
|
class HeapStats;
|
||||||
class Isolate;
|
class Isolate;
|
||||||
|
class IsolateSafepointScope;
|
||||||
class JSFinalizationRegistry;
|
class JSFinalizationRegistry;
|
||||||
class LinearAllocationArea;
|
class LinearAllocationArea;
|
||||||
class LocalEmbedderHeapTracer;
|
class LocalEmbedderHeapTracer;
|
||||||
@ -123,7 +124,6 @@ class PagedNewSpace;
|
|||||||
class ReadOnlyHeap;
|
class ReadOnlyHeap;
|
||||||
class RootVisitor;
|
class RootVisitor;
|
||||||
class RwxMemoryWriteScope;
|
class RwxMemoryWriteScope;
|
||||||
class SafepointScope;
|
|
||||||
class ScavengeJob;
|
class ScavengeJob;
|
||||||
class Scavenger;
|
class Scavenger;
|
||||||
class ScavengerCollector;
|
class ScavengerCollector;
|
||||||
@ -2751,7 +2751,7 @@ class V8_EXPORT_PRIVATE HeapObjectIterator {
|
|||||||
HeapObject NextObject();
|
HeapObject NextObject();
|
||||||
|
|
||||||
Heap* heap_;
|
Heap* heap_;
|
||||||
std::unique_ptr<SafepointScope> safepoint_scope_;
|
std::unique_ptr<IsolateSafepointScope> safepoint_scope_;
|
||||||
HeapObjectsFiltering filtering_;
|
HeapObjectsFiltering filtering_;
|
||||||
HeapObjectsFilter* filter_;
|
HeapObjectsFilter* filter_;
|
||||||
// Space iterator for iterating all the spaces.
|
// Space iterator for iterating all the spaces.
|
||||||
|
@ -335,11 +335,11 @@ class V8_EXPORT_PRIVATE LocalHeap {
|
|||||||
friend class CollectionBarrier;
|
friend class CollectionBarrier;
|
||||||
friend class ConcurrentAllocator;
|
friend class ConcurrentAllocator;
|
||||||
friend class GlobalSafepoint;
|
friend class GlobalSafepoint;
|
||||||
friend class IsolateSafepoint;
|
|
||||||
friend class Heap;
|
friend class Heap;
|
||||||
friend class Isolate;
|
friend class Isolate;
|
||||||
|
friend class IsolateSafepoint;
|
||||||
|
friend class IsolateSafepointScope;
|
||||||
friend class ParkedScope;
|
friend class ParkedScope;
|
||||||
friend class SafepointScope;
|
|
||||||
friend class UnparkedScope;
|
friend class UnparkedScope;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -282,11 +282,14 @@ Isolate* IsolateSafepoint::shared_heap_isolate() const {
|
|||||||
return isolate()->shared_heap_isolate();
|
return isolate()->shared_heap_isolate();
|
||||||
}
|
}
|
||||||
|
|
||||||
SafepointScope::SafepointScope(Heap* heap) : safepoint_(heap->safepoint()) {
|
IsolateSafepointScope::IsolateSafepointScope(Heap* heap)
|
||||||
|
: safepoint_(heap->safepoint()) {
|
||||||
safepoint_->EnterLocalSafepointScope();
|
safepoint_->EnterLocalSafepointScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
SafepointScope::~SafepointScope() { safepoint_->LeaveLocalSafepointScope(); }
|
IsolateSafepointScope::~IsolateSafepointScope() {
|
||||||
|
safepoint_->LeaveLocalSafepointScope();
|
||||||
|
}
|
||||||
|
|
||||||
GlobalSafepoint::GlobalSafepoint(Isolate* isolate)
|
GlobalSafepoint::GlobalSafepoint(Isolate* isolate)
|
||||||
: shared_heap_isolate_(isolate) {}
|
: shared_heap_isolate_(isolate) {}
|
||||||
@ -415,23 +418,22 @@ void GlobalSafepoint::LeaveGlobalSafepointScope(Isolate* initiator) {
|
|||||||
|
|
||||||
GlobalSafepointScope::GlobalSafepointScope(Isolate* initiator)
|
GlobalSafepointScope::GlobalSafepointScope(Isolate* initiator)
|
||||||
: initiator_(initiator),
|
: initiator_(initiator),
|
||||||
shared_heap_isolate_(initiator->has_shared_heap()
|
shared_heap_isolate_(initiator->shared_heap_isolate()) {
|
||||||
? initiator->shared_heap_isolate()
|
shared_heap_isolate_->global_safepoint()->EnterGlobalSafepointScope(
|
||||||
: nullptr) {
|
initiator_);
|
||||||
if (shared_heap_isolate_) {
|
|
||||||
shared_heap_isolate_->global_safepoint()->EnterGlobalSafepointScope(
|
|
||||||
initiator_);
|
|
||||||
} else {
|
|
||||||
initiator_->heap()->safepoint()->EnterLocalSafepointScope();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalSafepointScope::~GlobalSafepointScope() {
|
GlobalSafepointScope::~GlobalSafepointScope() {
|
||||||
if (shared_heap_isolate_) {
|
shared_heap_isolate_->global_safepoint()->LeaveGlobalSafepointScope(
|
||||||
shared_heap_isolate_->global_safepoint()->LeaveGlobalSafepointScope(
|
initiator_);
|
||||||
initiator_);
|
}
|
||||||
|
|
||||||
|
SafepointScope::SafepointScope(Isolate* initiator, SafepointKind kind) {
|
||||||
|
if (kind == SafepointKind::kIsolate) {
|
||||||
|
isolate_safepoint_.emplace(initiator->heap());
|
||||||
} else {
|
} else {
|
||||||
initiator_->heap()->safepoint()->LeaveLocalSafepointScope();
|
DCHECK_EQ(kind, SafepointKind::kGlobal);
|
||||||
|
global_safepoint_.emplace(initiator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,14 +148,14 @@ class IsolateSafepoint final {
|
|||||||
friend class GlobalSafepoint;
|
friend class GlobalSafepoint;
|
||||||
friend class GlobalSafepointScope;
|
friend class GlobalSafepointScope;
|
||||||
friend class Isolate;
|
friend class Isolate;
|
||||||
|
friend class IsolateSafepointScope;
|
||||||
friend class LocalHeap;
|
friend class LocalHeap;
|
||||||
friend class SafepointScope;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class V8_NODISCARD SafepointScope {
|
class V8_NODISCARD IsolateSafepointScope {
|
||||||
public:
|
public:
|
||||||
V8_EXPORT_PRIVATE explicit SafepointScope(Heap* heap);
|
V8_EXPORT_PRIVATE explicit IsolateSafepointScope(Heap* heap);
|
||||||
V8_EXPORT_PRIVATE ~SafepointScope();
|
V8_EXPORT_PRIVATE ~IsolateSafepointScope();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IsolateSafepoint* safepoint_;
|
IsolateSafepoint* safepoint_;
|
||||||
@ -204,6 +204,18 @@ class V8_NODISCARD GlobalSafepointScope {
|
|||||||
Isolate* const shared_heap_isolate_;
|
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<IsolateSafepointScope> isolate_safepoint_;
|
||||||
|
base::Optional<GlobalSafepointScope> global_safepoint_;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace v8
|
} // namespace v8
|
||||||
|
|
||||||
|
@ -2463,7 +2463,7 @@ void V8HeapExplorer::CollectGlobalObjectsTags() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void V8HeapExplorer::MakeGlobalObjectTagMap(
|
void V8HeapExplorer::MakeGlobalObjectTagMap(
|
||||||
const SafepointScope& safepoint_scope) {
|
const IsolateSafepointScope& safepoint_scope) {
|
||||||
for (const auto& pair : global_object_tag_pairs_) {
|
for (const auto& pair : global_object_tag_pairs_) {
|
||||||
global_object_tag_map_.emplace(*pair.first, pair.second);
|
global_object_tag_map_.emplace(*pair.first, pair.second);
|
||||||
}
|
}
|
||||||
@ -2723,7 +2723,7 @@ bool HeapSnapshotGenerator::GenerateSnapshot() {
|
|||||||
heap_->CollectAllAvailableGarbage(GarbageCollectionReason::kHeapProfiler);
|
heap_->CollectAllAvailableGarbage(GarbageCollectionReason::kHeapProfiler);
|
||||||
|
|
||||||
NullContextForSnapshotScope null_context_scope(isolate);
|
NullContextForSnapshotScope null_context_scope(isolate);
|
||||||
SafepointScope scope(heap_);
|
IsolateSafepointScope scope(heap_);
|
||||||
v8_heap_explorer_.MakeGlobalObjectTagMap(scope);
|
v8_heap_explorer_.MakeGlobalObjectTagMap(scope);
|
||||||
handle_scope.reset();
|
handle_scope.reset();
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ class HeapEntry;
|
|||||||
class HeapProfiler;
|
class HeapProfiler;
|
||||||
class HeapSnapshot;
|
class HeapSnapshot;
|
||||||
class HeapSnapshotGenerator;
|
class HeapSnapshotGenerator;
|
||||||
|
class IsolateSafepointScope;
|
||||||
class JSArrayBuffer;
|
class JSArrayBuffer;
|
||||||
class JSCollection;
|
class JSCollection;
|
||||||
class JSGeneratorObject;
|
class JSGeneratorObject;
|
||||||
@ -43,7 +44,6 @@ class JSGlobalObject;
|
|||||||
class JSGlobalProxy;
|
class JSGlobalProxy;
|
||||||
class JSPromise;
|
class JSPromise;
|
||||||
class JSWeakCollection;
|
class JSWeakCollection;
|
||||||
class SafepointScope;
|
|
||||||
|
|
||||||
struct SourceLocation {
|
struct SourceLocation {
|
||||||
SourceLocation(int entry_index, int scriptId, int line, int col)
|
SourceLocation(int entry_index, int scriptId, int line, int col)
|
||||||
@ -390,7 +390,7 @@ class V8_EXPORT_PRIVATE V8HeapExplorer : public HeapEntriesAllocator {
|
|||||||
uint32_t EstimateObjectsCount();
|
uint32_t EstimateObjectsCount();
|
||||||
bool IterateAndExtractReferences(HeapSnapshotGenerator* generator);
|
bool IterateAndExtractReferences(HeapSnapshotGenerator* generator);
|
||||||
void CollectGlobalObjectsTags();
|
void CollectGlobalObjectsTags();
|
||||||
void MakeGlobalObjectTagMap(const SafepointScope& safepoint_scope);
|
void MakeGlobalObjectTagMap(const IsolateSafepointScope& safepoint_scope);
|
||||||
void TagBuiltinCodeObject(CodeT code, const char* name);
|
void TagBuiltinCodeObject(CodeT code, const char* name);
|
||||||
HeapEntry* AddEntry(Address address,
|
HeapEntry* AddEntry(Address address,
|
||||||
HeapEntry::Type type,
|
HeapEntry::Type type,
|
||||||
|
@ -315,7 +315,10 @@ void Snapshot::SerializeDeserializeAndVerifyForTesting(
|
|||||||
|
|
||||||
// Test serialization.
|
// 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;
|
DisallowGarbageCollection no_gc;
|
||||||
|
|
||||||
Snapshot::SerializerFlags flags(
|
Snapshot::SerializerFlags flags(
|
||||||
@ -325,7 +328,7 @@ void Snapshot::SerializeDeserializeAndVerifyForTesting(
|
|||||||
? Snapshot::kReconstructReadOnlyAndSharedObjectCachesForTesting
|
? Snapshot::kReconstructReadOnlyAndSharedObjectCachesForTesting
|
||||||
: 0));
|
: 0));
|
||||||
serialized_data = Snapshot::Create(isolate, *default_context,
|
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);
|
auto_delete_serialized_data.reset(serialized_data.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,14 +372,14 @@ v8::StartupData Snapshot::Create(
|
|||||||
Isolate* isolate, std::vector<Context>* contexts,
|
Isolate* isolate, std::vector<Context>* contexts,
|
||||||
const std::vector<SerializeInternalFieldsCallback>&
|
const std::vector<SerializeInternalFieldsCallback>&
|
||||||
embedder_fields_serializers,
|
embedder_fields_serializers,
|
||||||
const GlobalSafepointScope& global_safepoint,
|
const SafepointScope& safepoint_scope,
|
||||||
const DisallowGarbageCollection& no_gc, SerializerFlags flags) {
|
const DisallowGarbageCollection& no_gc, SerializerFlags flags) {
|
||||||
TRACE_EVENT0("v8", "V8.SnapshotCreate");
|
TRACE_EVENT0("v8", "V8.SnapshotCreate");
|
||||||
DCHECK_EQ(contexts->size(), embedder_fields_serializers.size());
|
DCHECK_EQ(contexts->size(), embedder_fields_serializers.size());
|
||||||
DCHECK_GT(contexts->size(), 0);
|
DCHECK_GT(contexts->size(), 0);
|
||||||
HandleScope scope(isolate);
|
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
|
// string table is safe to iterate. Unlike mksnapshot, embedders may have
|
||||||
// background threads running.
|
// background threads running.
|
||||||
|
|
||||||
@ -453,13 +456,13 @@ v8::StartupData Snapshot::Create(
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
v8::StartupData Snapshot::Create(Isolate* isolate, Context default_context,
|
v8::StartupData Snapshot::Create(Isolate* isolate, Context default_context,
|
||||||
const GlobalSafepointScope& global_safepoint,
|
const SafepointScope& safepoint_scope,
|
||||||
const DisallowGarbageCollection& no_gc,
|
const DisallowGarbageCollection& no_gc,
|
||||||
SerializerFlags flags) {
|
SerializerFlags flags) {
|
||||||
std::vector<Context> contexts{default_context};
|
std::vector<Context> contexts{default_context};
|
||||||
std::vector<SerializeInternalFieldsCallback> callbacks{{}};
|
std::vector<SerializeInternalFieldsCallback> callbacks{{}};
|
||||||
return Snapshot::Create(isolate, &contexts, callbacks, global_safepoint,
|
return Snapshot::Create(isolate, &contexts, callbacks, safepoint_scope, no_gc,
|
||||||
no_gc, flags);
|
flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::StartupData SnapshotImpl::CreateSnapshotBlob(
|
v8::StartupData SnapshotImpl::CreateSnapshotBlob(
|
||||||
|
@ -15,10 +15,10 @@ namespace v8 {
|
|||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
class Context;
|
class Context;
|
||||||
class GlobalSafepointScope;
|
|
||||||
class Isolate;
|
class Isolate;
|
||||||
class SnapshotData;
|
|
||||||
class JSGlobalProxy;
|
class JSGlobalProxy;
|
||||||
|
class SafepointScope;
|
||||||
|
class SnapshotData;
|
||||||
|
|
||||||
class Snapshot : public AllStatic {
|
class Snapshot : public AllStatic {
|
||||||
public:
|
public:
|
||||||
@ -69,14 +69,14 @@ class Snapshot : public AllStatic {
|
|||||||
Isolate* isolate, std::vector<Context>* contexts,
|
Isolate* isolate, std::vector<Context>* contexts,
|
||||||
const std::vector<SerializeInternalFieldsCallback>&
|
const std::vector<SerializeInternalFieldsCallback>&
|
||||||
embedder_fields_serializers,
|
embedder_fields_serializers,
|
||||||
const GlobalSafepointScope& global_safepoint,
|
const SafepointScope& safepoint_scope,
|
||||||
const DisallowGarbageCollection& no_gc,
|
const DisallowGarbageCollection& no_gc,
|
||||||
SerializerFlags flags = kDefaultSerializerFlags);
|
SerializerFlags flags = kDefaultSerializerFlags);
|
||||||
|
|
||||||
// Convenience helper for the above when only serializing a single context.
|
// Convenience helper for the above when only serializing a single context.
|
||||||
static v8::StartupData Create(
|
static v8::StartupData Create(
|
||||||
Isolate* isolate, Context default_context,
|
Isolate* isolate, Context default_context,
|
||||||
const GlobalSafepointScope& global_safepoint,
|
const SafepointScope& safepoint_scope,
|
||||||
const DisallowGarbageCollection& no_gc,
|
const DisallowGarbageCollection& no_gc,
|
||||||
SerializerFlags flags = kDefaultSerializerFlags);
|
SerializerFlags flags = kDefaultSerializerFlags);
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ void SimulateIncrementalMarking(i::Heap* heap, bool force_completion) {
|
|||||||
i::IncrementalMarking* marking = heap->incremental_marking();
|
i::IncrementalMarking* marking = heap->incremental_marking();
|
||||||
|
|
||||||
if (heap->sweeping_in_progress()) {
|
if (heap->sweeping_in_progress()) {
|
||||||
SafepointScope scope(heap);
|
IsolateSafepointScope scope(heap);
|
||||||
heap->EnsureSweepingCompleted(
|
heap->EnsureSweepingCompleted(
|
||||||
Heap::SweepingForcedFinalizationMode::kV8Only);
|
Heap::SweepingForcedFinalizationMode::kV8Only);
|
||||||
}
|
}
|
||||||
@ -282,7 +282,7 @@ void SimulateIncrementalMarking(i::Heap* heap, bool force_completion) {
|
|||||||
CHECK(marking->IsMarking());
|
CHECK(marking->IsMarking());
|
||||||
if (!force_completion) return;
|
if (!force_completion) return;
|
||||||
|
|
||||||
SafepointScope scope(heap);
|
IsolateSafepointScope scope(heap);
|
||||||
MarkingBarrier::PublishAll(heap);
|
MarkingBarrier::PublishAll(heap);
|
||||||
marking->MarkRootsForTesting();
|
marking->MarkRootsForTesting();
|
||||||
|
|
||||||
@ -315,7 +315,7 @@ void AbandonCurrentlyFreeMemory(PagedSpace* space) {
|
|||||||
void GcAndSweep(Heap* heap, AllocationSpace space) {
|
void GcAndSweep(Heap* heap, AllocationSpace space) {
|
||||||
heap->CollectGarbage(space, GarbageCollectionReason::kTesting);
|
heap->CollectGarbage(space, GarbageCollectionReason::kTesting);
|
||||||
if (heap->sweeping_in_progress()) {
|
if (heap->sweeping_in_progress()) {
|
||||||
SafepointScope scope(heap);
|
IsolateSafepointScope scope(heap);
|
||||||
heap->EnsureSweepingCompleted(
|
heap->EnsureSweepingCompleted(
|
||||||
Heap::SweepingForcedFinalizationMode::kV8Only);
|
Heap::SweepingForcedFinalizationMode::kV8Only);
|
||||||
}
|
}
|
||||||
@ -343,14 +343,14 @@ bool InCorrectGeneration(HeapObject object) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GrowNewSpace(Heap* heap) {
|
void GrowNewSpace(Heap* heap) {
|
||||||
SafepointScope scope(heap);
|
IsolateSafepointScope scope(heap);
|
||||||
if (!heap->new_space()->IsAtMaximumCapacity()) {
|
if (!heap->new_space()->IsAtMaximumCapacity()) {
|
||||||
heap->new_space()->Grow();
|
heap->new_space()->Grow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrowNewSpaceToMaximumCapacity(Heap* heap) {
|
void GrowNewSpaceToMaximumCapacity(Heap* heap) {
|
||||||
SafepointScope scope(heap);
|
IsolateSafepointScope scope(heap);
|
||||||
while (!heap->new_space()->IsAtMaximumCapacity()) {
|
while (!heap->new_space()->IsAtMaximumCapacity()) {
|
||||||
heap->new_space()->Grow();
|
heap->new_space()->Grow();
|
||||||
}
|
}
|
||||||
|
@ -5860,7 +5860,7 @@ TEST(Regress598319) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SafepointScope safepoint_scope(heap);
|
IsolateSafepointScope safepoint_scope(heap);
|
||||||
MarkingBarrier::PublishAll(heap);
|
MarkingBarrier::PublishAll(heap);
|
||||||
|
|
||||||
// Finish marking with bigger steps to speed up test.
|
// Finish marking with bigger steps to speed up test.
|
||||||
@ -6566,7 +6566,7 @@ HEAP_TEST(Regress670675) {
|
|||||||
heap->tracer()->StopFullCycleIfNeeded();
|
heap->tracer()->StopFullCycleIfNeeded();
|
||||||
i::IncrementalMarking* marking = CcTest::heap()->incremental_marking();
|
i::IncrementalMarking* marking = CcTest::heap()->incremental_marking();
|
||||||
if (marking->IsStopped()) {
|
if (marking->IsStopped()) {
|
||||||
SafepointScope safepoint_scope(heap);
|
IsolateSafepointScope safepoint_scope(heap);
|
||||||
heap->tracer()->StartCycle(
|
heap->tracer()->StartCycle(
|
||||||
GarbageCollector::MARK_COMPACTOR, GarbageCollectionReason::kTesting,
|
GarbageCollector::MARK_COMPACTOR, GarbageCollectionReason::kTesting,
|
||||||
"collector cctest", GCTracer::MarkingType::kIncremental);
|
"collector cctest", GCTracer::MarkingType::kIncremental);
|
||||||
|
@ -118,7 +118,7 @@ TEST_WITH_PLATFORM(IncrementalMarkingUsingTasks, MockPlatform) {
|
|||||||
i::IncrementalMarking* marking = heap->incremental_marking();
|
i::IncrementalMarking* marking = heap->incremental_marking();
|
||||||
marking->Stop();
|
marking->Stop();
|
||||||
{
|
{
|
||||||
SafepointScope scope(heap);
|
IsolateSafepointScope scope(heap);
|
||||||
heap->tracer()->StartCycle(
|
heap->tracer()->StartCycle(
|
||||||
GarbageCollector::MARK_COMPACTOR, GarbageCollectionReason::kTesting,
|
GarbageCollector::MARK_COMPACTOR, GarbageCollectionReason::kTesting,
|
||||||
"collector cctest", GCTracer::MarkingType::kIncremental);
|
"collector cctest", GCTracer::MarkingType::kIncremental);
|
||||||
|
@ -161,7 +161,7 @@ static unsigned int PseudorandomAreaSize() {
|
|||||||
TEST(MemoryChunk) {
|
TEST(MemoryChunk) {
|
||||||
Isolate* isolate = CcTest::i_isolate();
|
Isolate* isolate = CcTest::i_isolate();
|
||||||
Heap* heap = isolate->heap();
|
Heap* heap = isolate->heap();
|
||||||
SafepointScope safepoint(heap);
|
IsolateSafepointScope safepoint(heap);
|
||||||
|
|
||||||
v8::PageAllocator* page_allocator = GetPlatformPageAllocator();
|
v8::PageAllocator* page_allocator = GetPlatformPageAllocator();
|
||||||
size_t area_size;
|
size_t area_size;
|
||||||
|
@ -210,7 +210,7 @@ static StartupBlobs Serialize(v8::Isolate* isolate) {
|
|||||||
Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate);
|
Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate);
|
||||||
CcTest::CollectAllAvailableGarbage(i_isolate);
|
CcTest::CollectAllAvailableGarbage(i_isolate);
|
||||||
|
|
||||||
SafepointScope safepoint(i_isolate->heap());
|
IsolateSafepointScope safepoint(i_isolate->heap());
|
||||||
HandleScope scope(i_isolate);
|
HandleScope scope(i_isolate);
|
||||||
|
|
||||||
DisallowGarbageCollection no_gc;
|
DisallowGarbageCollection no_gc;
|
||||||
@ -403,7 +403,7 @@ static void SerializeContext(base::Vector<const byte>* startup_blob_out,
|
|||||||
|
|
||||||
env.Reset();
|
env.Reset();
|
||||||
|
|
||||||
SafepointScope safepoint(heap);
|
IsolateSafepointScope safepoint(heap);
|
||||||
|
|
||||||
DisallowGarbageCollection no_gc;
|
DisallowGarbageCollection no_gc;
|
||||||
SnapshotByteSink read_only_sink;
|
SnapshotByteSink read_only_sink;
|
||||||
@ -572,7 +572,7 @@ static void SerializeCustomContext(
|
|||||||
|
|
||||||
env.Reset();
|
env.Reset();
|
||||||
|
|
||||||
SafepointScope safepoint(isolate->heap());
|
IsolateSafepointScope safepoint(isolate->heap());
|
||||||
|
|
||||||
DisallowGarbageCollection no_gc;
|
DisallowGarbageCollection no_gc;
|
||||||
SnapshotByteSink read_only_sink;
|
SnapshotByteSink read_only_sink;
|
||||||
|
@ -127,7 +127,7 @@ static int DumpHeapConstants(FILE* out, const char* argv0) {
|
|||||||
{
|
{
|
||||||
Isolate::Scope scope(isolate);
|
Isolate::Scope scope(isolate);
|
||||||
i::Heap* heap = reinterpret_cast<i::Isolate*>(isolate)->heap();
|
i::Heap* heap = reinterpret_cast<i::Isolate*>(isolate)->heap();
|
||||||
i::SafepointScope safepoint_scope(heap);
|
i::IsolateSafepointScope safepoint_scope(heap);
|
||||||
i::ReadOnlyHeap* read_only_heap =
|
i::ReadOnlyHeap* read_only_heap =
|
||||||
reinterpret_cast<i::Isolate*>(isolate)->read_only_heap();
|
reinterpret_cast<i::Isolate*>(isolate)->read_only_heap();
|
||||||
i::PrintF(out, "%s", kHeader);
|
i::PrintF(out, "%s", kHeader);
|
||||||
|
@ -466,7 +466,7 @@ TEST_F(EmbedderTracingTest, FinalizeTracingWhenMarking) {
|
|||||||
|
|
||||||
i::IncrementalMarking* marking = heap->incremental_marking();
|
i::IncrementalMarking* marking = heap->incremental_marking();
|
||||||
{
|
{
|
||||||
SafepointScope scope(heap);
|
IsolateSafepointScope scope(heap);
|
||||||
heap->tracer()->StartCycle(
|
heap->tracer()->StartCycle(
|
||||||
GarbageCollector::MARK_COMPACTOR, GarbageCollectionReason::kTesting,
|
GarbageCollector::MARK_COMPACTOR, GarbageCollectionReason::kTesting,
|
||||||
"collector cctest", GCTracer::MarkingType::kIncremental);
|
"collector cctest", GCTracer::MarkingType::kIncremental);
|
||||||
|
@ -162,7 +162,7 @@ TEST_F(HeapTest, HeapLayout) {
|
|||||||
base::AddressRegion heap_reservation(cage_base, size_t{4} * GB);
|
base::AddressRegion heap_reservation(cage_base, size_t{4} * GB);
|
||||||
base::AddressRegion code_reservation(code_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());
|
OldGenerationMemoryChunkIterator iter(i_isolate()->heap());
|
||||||
for (;;) {
|
for (;;) {
|
||||||
MemoryChunk* chunk = iter.next();
|
MemoryChunk* chunk = iter.next();
|
||||||
@ -373,7 +373,7 @@ TEST_F(HeapTest, RememberedSet_InsertOnPromotingObjectToOld) {
|
|||||||
CHECK(!new_space->IsAtMaximumCapacity());
|
CHECK(!new_space->IsAtMaximumCapacity());
|
||||||
// Fill current pages to force MinorMC to promote them.
|
// Fill current pages to force MinorMC to promote them.
|
||||||
SimulateFullSpace(new_space, &handles);
|
SimulateFullSpace(new_space, &handles);
|
||||||
SafepointScope scope(heap);
|
IsolateSafepointScope scope(heap);
|
||||||
// New empty pages should remain in new space.
|
// New empty pages should remain in new space.
|
||||||
new_space->Grow();
|
new_space->Grow();
|
||||||
} else {
|
} else {
|
||||||
@ -422,7 +422,7 @@ TEST_F(HeapTest, Regress978156) {
|
|||||||
// 5. Start incremental marking.
|
// 5. Start incremental marking.
|
||||||
i::IncrementalMarking* marking = heap->incremental_marking();
|
i::IncrementalMarking* marking = heap->incremental_marking();
|
||||||
if (marking->IsStopped()) {
|
if (marking->IsStopped()) {
|
||||||
SafepointScope scope(heap);
|
IsolateSafepointScope scope(heap);
|
||||||
heap->tracer()->StartCycle(
|
heap->tracer()->StartCycle(
|
||||||
GarbageCollector::MARK_COMPACTOR, GarbageCollectionReason::kTesting,
|
GarbageCollector::MARK_COMPACTOR, GarbageCollectionReason::kTesting,
|
||||||
"collector cctest", GCTracer::MarkingType::kIncremental);
|
"collector cctest", GCTracer::MarkingType::kIncremental);
|
||||||
|
@ -24,7 +24,7 @@ void HeapInternalsBase::SimulateIncrementalMarking(Heap* heap,
|
|||||||
i::IncrementalMarking* marking = heap->incremental_marking();
|
i::IncrementalMarking* marking = heap->incremental_marking();
|
||||||
|
|
||||||
if (heap->sweeping_in_progress()) {
|
if (heap->sweeping_in_progress()) {
|
||||||
SafepointScope scope(heap);
|
IsolateSafepointScope scope(heap);
|
||||||
heap->EnsureSweepingCompleted(
|
heap->EnsureSweepingCompleted(
|
||||||
Heap::SweepingForcedFinalizationMode::kV8Only);
|
Heap::SweepingForcedFinalizationMode::kV8Only);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ class WithHeapInternals : public TMixin, HeapInternalsBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GrowNewSpace() {
|
void GrowNewSpace() {
|
||||||
SafepointScope scope(heap());
|
IsolateSafepointScope scope(heap());
|
||||||
if (!heap()->new_space()->IsAtMaximumCapacity()) {
|
if (!heap()->new_space()->IsAtMaximumCapacity()) {
|
||||||
heap()->new_space()->Grow();
|
heap()->new_space()->Grow();
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ class WithHeapInternals : public TMixin, HeapInternalsBase {
|
|||||||
void GcAndSweep(i::AllocationSpace space) {
|
void GcAndSweep(i::AllocationSpace space) {
|
||||||
heap()->CollectGarbage(space, GarbageCollectionReason::kTesting);
|
heap()->CollectGarbage(space, GarbageCollectionReason::kTesting);
|
||||||
if (heap()->sweeping_in_progress()) {
|
if (heap()->sweeping_in_progress()) {
|
||||||
SafepointScope scope(heap());
|
IsolateSafepointScope scope(heap());
|
||||||
heap()->EnsureSweepingCompleted(
|
heap()->EnsureSweepingCompleted(
|
||||||
Heap::SweepingForcedFinalizationMode::kV8Only);
|
Heap::SweepingForcedFinalizationMode::kV8Only);
|
||||||
}
|
}
|
||||||
|
@ -680,7 +680,7 @@ TEST_F(InnerPointerResolutionHeapTest, UnusedRegularYoungPages) {
|
|||||||
// Start incremental marking and mark the third object.
|
// Start incremental marking and mark the third object.
|
||||||
i::IncrementalMarking* marking = heap()->incremental_marking();
|
i::IncrementalMarking* marking = heap()->incremental_marking();
|
||||||
if (marking->IsStopped()) {
|
if (marking->IsStopped()) {
|
||||||
SafepointScope scope(heap());
|
IsolateSafepointScope scope(heap());
|
||||||
heap()->tracer()->StartCycle(
|
heap()->tracer()->StartCycle(
|
||||||
GarbageCollector::MARK_COMPACTOR, GarbageCollectionReason::kTesting,
|
GarbageCollector::MARK_COMPACTOR, GarbageCollectionReason::kTesting,
|
||||||
"unit test", GCTracer::MarkingType::kIncremental);
|
"unit test", GCTracer::MarkingType::kIncremental);
|
||||||
|
@ -21,7 +21,7 @@ TEST_F(SafepointTest, ReachSafepointWithoutLocalHeaps) {
|
|||||||
Heap* heap = i_isolate()->heap();
|
Heap* heap = i_isolate()->heap();
|
||||||
bool run = false;
|
bool run = false;
|
||||||
{
|
{
|
||||||
SafepointScope scope(heap);
|
IsolateSafepointScope scope(heap);
|
||||||
run = true;
|
run = true;
|
||||||
}
|
}
|
||||||
CHECK(run);
|
CHECK(run);
|
||||||
@ -68,7 +68,7 @@ TEST_F(SafepointTest, StopParkedThreads) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SafepointScope scope(heap);
|
IsolateSafepointScope scope(heap);
|
||||||
safepoints++;
|
safepoints++;
|
||||||
}
|
}
|
||||||
mutex.Unlock();
|
mutex.Unlock();
|
||||||
@ -124,7 +124,7 @@ TEST_F(SafepointTest, StopRunningThreads) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < kSafepoints; i++) {
|
for (int i = 0; i < kSafepoints; i++) {
|
||||||
SafepointScope scope(heap);
|
IsolateSafepointScope scope(heap);
|
||||||
safepoint_count++;
|
safepoint_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user