Commit 6a2cf923 authored by Dominik Inführ's avatar Dominik Inführ Committed by V8 LUCI CQ

[snapshot] Pass GlobalSafepointScope to Snapshot::Create

Instead of just DCHECKing that we are in a safepoint in
Snapshot::Create, pass the GlobalSafepointScope as argument.

Bug: v8:11708, v8:12377
Change-Id: Ia856c27b92223bf3a96fe6946b86e4625f3a1e0f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3295342Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78014}
parent 2c88cec4
......@@ -716,7 +716,7 @@ StartupData SnapshotCreator::CreateBlob(
data->created_ = true;
return i::Snapshot::Create(isolate, &contexts, embedder_fields_serializers,
no_gc_from_here_on);
global_safepoint, no_gc_from_here_on);
}
bool StartupData::CanBeRehashed() const {
......
......@@ -341,7 +341,8 @@ void Snapshot::SerializeDeserializeAndVerifyForTesting(
(ReadOnlyHeap::IsReadOnlySpaceShared()
? Snapshot::kReconstructReadOnlyObjectCacheForTesting
: 0));
serialized_data = Snapshot::Create(isolate, *default_context, no_gc, flags);
serialized_data = Snapshot::Create(isolate, *default_context,
global_safepoint, no_gc, flags);
auto_delete_serialized_data.reset(serialized_data.data);
}
......@@ -379,15 +380,16 @@ v8::StartupData Snapshot::Create(
Isolate* isolate, std::vector<Context>* contexts,
const std::vector<SerializeInternalFieldsCallback>&
embedder_fields_serializers,
const GlobalSafepointScope& global_safepoint,
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);
// Ensure we are in a safepoint scope so that the string table is safe to
// iterate. Unlike mksnapshot, embedders may have background threads running.
isolate->heap()->safepoint()->AssertActive();
// The GlobalSafepointScope ensures we are in a safepoint scope so that the
// string table is safe to iterate. Unlike mksnapshot, embedders may have
// background threads running.
ReadOnlySerializer read_only_serializer(isolate, flags);
read_only_serializer.SerializeReadOnlyRoots();
......@@ -462,11 +464,13 @@ v8::StartupData Snapshot::Create(
// static
v8::StartupData Snapshot::Create(Isolate* isolate, Context default_context,
const GlobalSafepointScope& global_safepoint,
const DisallowGarbageCollection& no_gc,
SerializerFlags flags) {
std::vector<Context> contexts{default_context};
std::vector<SerializeInternalFieldsCallback> callbacks{{}};
return Snapshot::Create(isolate, &contexts, callbacks, no_gc, flags);
return Snapshot::Create(isolate, &contexts, callbacks, global_safepoint,
no_gc, flags);
}
v8::StartupData SnapshotImpl::CreateSnapshotBlob(
......
......@@ -13,6 +13,7 @@ namespace v8 {
namespace internal {
class Context;
class GlobalSafepointScope;
class Isolate;
class SnapshotData;
class JSGlobalProxy;
......@@ -64,12 +65,14 @@ class Snapshot : public AllStatic {
Isolate* isolate, std::vector<Context>* contexts,
const std::vector<SerializeInternalFieldsCallback>&
embedder_fields_serializers,
const GlobalSafepointScope& global_safepoint,
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 DisallowGarbageCollection& no_gc,
SerializerFlags flags = kDefaultSerializerFlags);
......
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