Commit bee5b996 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[serializer] Remove Deserializer::Initialize

Remove the separate Initialize method from Deserializer, opting instead
to pass around SnapshotData where appropriate and pass the isolate
directly into the Deserializer's constructor.

Change-Id: I0092fadd9c81f14b2ce75145fd81af37c3947c65
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2448466
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70310}
parent f6bc6b6d
......@@ -3397,13 +3397,14 @@ void Isolate::TearDownEmbeddedBlob() {
}
}
bool Isolate::InitWithoutSnapshot() { return Init(nullptr, nullptr); }
bool Isolate::InitWithoutSnapshot() { return Init(nullptr, nullptr, false); }
bool Isolate::InitWithSnapshot(ReadOnlyDeserializer* read_only_deserializer,
StartupDeserializer* startup_deserializer) {
DCHECK_NOT_NULL(read_only_deserializer);
DCHECK_NOT_NULL(startup_deserializer);
return Init(read_only_deserializer, startup_deserializer);
bool Isolate::InitWithSnapshot(SnapshotData* startup_snapshot_data,
SnapshotData* read_only_snapshot_data,
bool can_rehash) {
DCHECK_NOT_NULL(startup_snapshot_data);
DCHECK_NOT_NULL(read_only_snapshot_data);
return Init(startup_snapshot_data, read_only_snapshot_data, can_rehash);
}
static std::string AddressToString(uintptr_t address) {
......@@ -3452,12 +3453,12 @@ using MapOfLoadsAndStoresPerFunction =
MapOfLoadsAndStoresPerFunction* stack_access_count_map = nullptr;
} // namespace
bool Isolate::Init(ReadOnlyDeserializer* read_only_deserializer,
StartupDeserializer* startup_deserializer) {
bool Isolate::Init(SnapshotData* startup_snapshot_data,
SnapshotData* read_only_snapshot_data, bool can_rehash) {
TRACE_ISOLATE(init);
const bool create_heap_objects = (read_only_deserializer == nullptr);
const bool create_heap_objects = (read_only_snapshot_data == nullptr);
// We either have both or neither.
DCHECK_EQ(create_heap_objects, startup_deserializer == nullptr);
DCHECK_EQ(create_heap_objects, startup_snapshot_data == nullptr);
base::ElapsedTimer timer;
if (create_heap_objects && FLAG_profile_deserialization) timer.Start();
......@@ -3518,7 +3519,7 @@ bool Isolate::Init(ReadOnlyDeserializer* read_only_deserializer,
// SetUp the object heap.
DCHECK(!heap_.HasBeenSetUp());
heap_.SetUp();
ReadOnlyHeap::SetUp(this, read_only_deserializer);
ReadOnlyHeap::SetUp(this, read_only_snapshot_data, can_rehash);
heap_.SetUpSpaces();
isolate_data_.external_reference_table()->Init(this);
......@@ -3609,7 +3610,9 @@ bool Isolate::Init(ReadOnlyDeserializer* read_only_deserializer,
heap_.read_only_space()->ClearStringPaddingIfNeeded();
read_only_heap_->OnCreateHeapObjectsComplete(this);
} else {
startup_deserializer->DeserializeInto(this);
StartupDeserializer startup_deserializer(this, startup_snapshot_data,
can_rehash);
startup_deserializer.DeserializeIntoIsolate();
}
load_stub_cache_->Initialize();
store_stub_cache_->Initialize();
......
......@@ -92,14 +92,13 @@ class OptimizingCompileDispatcher;
class PersistentHandles;
class PersistentHandlesList;
class ReadOnlyArtifacts;
class ReadOnlyDeserializer;
class RegExpStack;
class RootVisitor;
class RuntimeProfiler;
class SetupIsolateDelegate;
class Simulator;
class SnapshotData;
class StandardFrame;
class StartupDeserializer;
class StringTable;
class StubCache;
class ThreadManager;
......@@ -570,8 +569,8 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
bool InitializeCounters(); // Returns false if already initialized.
bool InitWithoutSnapshot();
bool InitWithSnapshot(ReadOnlyDeserializer* read_only_deserializer,
StartupDeserializer* startup_deserializer);
bool InitWithSnapshot(SnapshotData* startup_snapshot_data,
SnapshotData* read_only_snapshot_data, bool can_rehash);
// True if at least one thread Enter'ed this isolate.
bool IsInUse() { return entry_stack_ != nullptr; }
......@@ -1596,8 +1595,8 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
explicit Isolate(std::unique_ptr<IsolateAllocator> isolate_allocator);
~Isolate();
bool Init(ReadOnlyDeserializer* read_only_deserializer,
StartupDeserializer* startup_deserializer);
bool Init(SnapshotData* startup_snapshot_data,
SnapshotData* read_only_snapshot_data, bool can_rehash);
void CheckIsolateLayout();
......
......@@ -60,21 +60,24 @@ bool ReadOnlyHeap::IsSharedMemoryAvailable() {
SoleReadOnlyHeap* SoleReadOnlyHeap::shared_ro_heap_ = nullptr;
// static
void ReadOnlyHeap::SetUp(Isolate* isolate, ReadOnlyDeserializer* des) {
void ReadOnlyHeap::SetUp(Isolate* isolate,
SnapshotData* read_only_snapshot_data,
bool can_rehash) {
DCHECK_NOT_NULL(isolate);
if (IsReadOnlySpaceShared()) {
ReadOnlyHeap* ro_heap;
if (des != nullptr) {
if (read_only_snapshot_data != nullptr) {
bool read_only_heap_created = false;
base::MutexGuard guard(read_only_heap_creation_mutex_.Pointer());
std::shared_ptr<ReadOnlyArtifacts> artifacts =
read_only_artifacts_.Get().lock();
if (!artifacts) {
artifacts = InitializeSharedReadOnlyArtifacts();
artifacts->InitializeChecksum(des);
artifacts->InitializeChecksum(read_only_snapshot_data);
ro_heap = CreateInitalHeapForBootstrapping(isolate, artifacts);
ro_heap->DeseralizeIntoIsolate(isolate, des);
ro_heap->DeseralizeIntoIsolate(isolate, read_only_snapshot_data,
can_rehash);
read_only_heap_created = true;
} else {
// With pointer compression, there is one ReadOnlyHeap per Isolate.
......@@ -82,7 +85,8 @@ void ReadOnlyHeap::SetUp(Isolate* isolate, ReadOnlyDeserializer* des) {
ro_heap = artifacts->GetReadOnlyHeapForIsolate(isolate);
isolate->SetUpFromReadOnlyArtifacts(artifacts, ro_heap);
}
artifacts->VerifyChecksum(des, read_only_heap_created);
artifacts->VerifyChecksum(read_only_snapshot_data,
read_only_heap_created);
ro_heap->InitializeIsolateRoots(isolate);
} else {
// This path should only be taken in mksnapshot, should only be run once
......@@ -94,21 +98,24 @@ void ReadOnlyHeap::SetUp(Isolate* isolate, ReadOnlyDeserializer* des) {
artifacts = InitializeSharedReadOnlyArtifacts();
ro_heap = CreateInitalHeapForBootstrapping(isolate, artifacts);
artifacts->VerifyChecksum(des, true);
artifacts->VerifyChecksum(read_only_snapshot_data, true);
}
} else {
auto* ro_heap = new ReadOnlyHeap(new ReadOnlySpace(isolate->heap()));
isolate->SetUpFromReadOnlyArtifacts(nullptr, ro_heap);
if (des != nullptr) {
ro_heap->DeseralizeIntoIsolate(isolate, des);
if (read_only_snapshot_data != nullptr) {
ro_heap->DeseralizeIntoIsolate(isolate, read_only_snapshot_data,
can_rehash);
}
}
}
void ReadOnlyHeap::DeseralizeIntoIsolate(Isolate* isolate,
ReadOnlyDeserializer* des) {
DCHECK_NOT_NULL(des);
des->DeserializeInto(isolate);
SnapshotData* read_only_snapshot_data,
bool can_rehash) {
DCHECK_NOT_NULL(read_only_snapshot_data);
ReadOnlyDeserializer des(isolate, read_only_snapshot_data, can_rehash);
des.DeserializeIntoIsolate();
InitFromIsolate(isolate);
}
......
......@@ -25,10 +25,10 @@ class BasicMemoryChunk;
class Isolate;
class Page;
class ReadOnlyArtifacts;
class ReadOnlyDeserializer;
class ReadOnlyPage;
class ReadOnlySpace;
class SharedReadOnlySpace;
class SnapshotData;
// This class transparently manages read-only space, roots and cache creation
// and destruction.
......@@ -47,7 +47,8 @@ class ReadOnlyHeap {
// V8_SHARED_RO_HEAP is enabled, a lock will be held until that method is
// called.
// TODO(v8:7464): Ideally we'd create this without needing a heap.
static void SetUp(Isolate* isolate, ReadOnlyDeserializer* des);
static void SetUp(Isolate* isolate, SnapshotData* read_only_snapshot_data,
bool can_rehash);
// Indicates that the isolate has been set up and all read-only space objects
// have been created and will not be written to. This should only be called if
// a deserializer was not previously provided to Setup. When V8_SHARED_RO_HEAP
......@@ -101,7 +102,9 @@ class ReadOnlyHeap {
Isolate* isolate, std::shared_ptr<ReadOnlyArtifacts> artifacts);
// Runs the read-only deserializer and calls InitFromIsolate to complete
// read-only heap initialization.
void DeseralizeIntoIsolate(Isolate* isolate, ReadOnlyDeserializer* des);
void DeseralizeIntoIsolate(Isolate* isolate,
SnapshotData* read_only_snapshot_data,
bool can_rehash);
// Initializes read-only heap from an already set-up isolate, copying
// read-only roots from the isolate. This then seals the space off from
// further writes, marks it as read-only and detaches it from the heap
......
......@@ -39,22 +39,24 @@ void ReadOnlyArtifacts::set_read_only_heap(
read_only_heap_ = std::move(read_only_heap);
}
void ReadOnlyArtifacts::InitializeChecksum(ReadOnlyDeserializer* des) {
void ReadOnlyArtifacts::InitializeChecksum(
SnapshotData* read_only_snapshot_data) {
#ifdef DEBUG
read_only_blob_checksum_ = des->GetChecksum();
read_only_blob_checksum_ = Checksum(read_only_snapshot_data->Payload());
#endif // DEBUG
}
void ReadOnlyArtifacts::VerifyChecksum(ReadOnlyDeserializer* des,
void ReadOnlyArtifacts::VerifyChecksum(SnapshotData* read_only_snapshot_data,
bool read_only_heap_created) {
#ifdef DEBUG
if (read_only_blob_checksum_) {
// The read-only heap was set up from a snapshot. Make sure it's the always
// the same snapshot.
CHECK_WITH_MSG(des->GetChecksum(),
uint32_t snapshot_checksum = Checksum(read_only_snapshot_data->Payload());
CHECK_WITH_MSG(snapshot_checksum,
"Attempt to create the read-only heap after already "
"creating from a snapshot.");
CHECK_EQ(read_only_blob_checksum_, des->GetChecksum());
CHECK_EQ(read_only_blob_checksum_, snapshot_checksum);
} else {
// If there's no checksum, then that means the read-only heap objects are
// being created.
......
......@@ -20,9 +20,9 @@
namespace v8 {
namespace internal {
class ReadOnlyDeserializer;
class MemoryAllocator;
class ReadOnlyHeap;
class SnapshotData;
class ReadOnlyPage : public BasicMemoryChunk {
public:
......@@ -100,8 +100,9 @@ class ReadOnlyArtifacts {
void set_read_only_heap(std::unique_ptr<ReadOnlyHeap> read_only_heap);
ReadOnlyHeap* read_only_heap() const { return read_only_heap_.get(); }
void InitializeChecksum(ReadOnlyDeserializer* des);
void VerifyChecksum(ReadOnlyDeserializer* des, bool read_only_heap_created);
void InitializeChecksum(SnapshotData* read_only_snapshot_data);
void VerifyChecksum(SnapshotData* read_only_snapshot_data,
bool read_only_heap_created);
protected:
ReadOnlyArtifacts() = default;
......
......@@ -17,8 +17,7 @@ MaybeHandle<Context> ContextDeserializer::DeserializeContext(
Isolate* isolate, const SnapshotData* data, bool can_rehash,
Handle<JSGlobalProxy> global_proxy,
v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer) {
ContextDeserializer d(data);
d.SetRehashability(can_rehash);
ContextDeserializer d(isolate, data, can_rehash);
MaybeHandle<Object> maybe_result =
d.Deserialize(isolate, global_proxy, embedder_fields_deserializer);
......@@ -31,8 +30,6 @@ MaybeHandle<Context> ContextDeserializer::DeserializeContext(
MaybeHandle<Object> ContextDeserializer::Deserialize(
Isolate* isolate, Handle<JSGlobalProxy> global_proxy,
v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer) {
Initialize(isolate);
// Replace serialized references to the global proxy and its map with the
// given global proxy and its map.
AddAttachedObject(global_proxy);
......
......@@ -13,6 +13,7 @@ namespace v8 {
namespace internal {
class Context;
class Isolate;
// Deserializes the context-dependent object graph rooted at a given object.
// The ContextDeserializer is not expected to deserialize any code objects.
......@@ -24,8 +25,10 @@ class V8_EXPORT_PRIVATE ContextDeserializer final : public Deserializer {
v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer);
private:
explicit ContextDeserializer(const SnapshotData* data)
: Deserializer(data, false) {}
explicit ContextDeserializer(Isolate* isolate, const SnapshotData* data,
bool can_rehash)
: Deserializer(isolate, data->Payload(), data->GetMagicNumber(), false,
can_rehash) {}
// Deserialize a single object and the objects reachable from it.
MaybeHandle<Object> Deserialize(
......
......@@ -194,12 +194,23 @@ int Deserializer::WriteExternalPointer(TSlot dest, Address value) {
return (kExternalPointerSize / TSlot::kSlotDataSize);
}
void Deserializer::Initialize(Isolate* isolate) {
DCHECK_NULL(isolate_);
Deserializer::Deserializer(Isolate* isolate, Vector<const byte> payload,
uint32_t magic_number, bool deserializing_user_code,
bool can_rehash)
: isolate_(isolate),
source_(payload),
magic_number_(magic_number),
deserializing_user_code_(deserializing_user_code),
can_rehash_(can_rehash) {
DCHECK_NOT_NULL(isolate);
isolate_ = isolate;
isolate_->RegisterDeserializerStarted();
// We start the indices here at 1, so that we can distinguish between an
// actual index and a nullptr (serialized as kNullRefSentinel) in a
// deserialized object requiring fix-up.
STATIC_ASSERT(kNullRefSentinel == 0);
backing_stores_.push_back({});
#ifdef DEBUG
num_api_references_ = 0;
// The read-only deserializer is run by read-only heap set-up before the
......@@ -234,7 +245,7 @@ Deserializer::~Deserializer() {
DCHECK_EQ(num_unresolved_forward_refs_, 0);
DCHECK(unresolved_forward_refs_.empty());
#endif // DEBUG
if (isolate_) isolate_->RegisterDeserializerFinished();
isolate_->RegisterDeserializerFinished();
}
// This is called on the roots. It is the driver of the deserialization
......
......@@ -47,26 +47,14 @@ class V8_EXPORT_PRIVATE Deserializer : public SerializerDeserializer {
~Deserializer() override;
void SetRehashability(bool v) { can_rehash_ = v; }
uint32_t GetChecksum() const { return source_.GetChecksum(); }
protected:
// Create a deserializer from a snapshot byte source.
template <class Data>
Deserializer(Data* data, bool deserializing_user_code)
: isolate_(nullptr),
source_(data->Payload()),
magic_number_(data->GetMagicNumber()),
deserializing_user_code_(deserializing_user_code),
can_rehash_(false) {
// We start the indices here at 1, so that we can distinguish between an
// actual index and a nullptr (serialized as kNullRefSentinel) in a
// deserialized object requiring fix-up.
STATIC_ASSERT(kNullRefSentinel == 0);
backing_stores_.push_back({});
}
Deserializer(Isolate* isolate, Vector<const byte> payload,
uint32_t magic_number, bool deserializing_user_code,
bool can_rehash);
void Initialize(Isolate* isolate);
void DeserializeDeferredObjects();
// Create Log events for newly deserialized objects.
......
......@@ -15,18 +15,20 @@
namespace v8 {
namespace internal {
ObjectDeserializer::ObjectDeserializer(const SerializedCodeData* data)
: Deserializer(data, true) {}
ObjectDeserializer::ObjectDeserializer(Isolate* isolate,
const SerializedCodeData* data)
: Deserializer(isolate, data->Payload(), data->GetMagicNumber(), true,
false) {}
MaybeHandle<SharedFunctionInfo>
ObjectDeserializer::DeserializeSharedFunctionInfo(
Isolate* isolate, const SerializedCodeData* data, Handle<String> source) {
ObjectDeserializer d(data);
ObjectDeserializer d(isolate, data);
d.AddAttachedObject(source);
Handle<HeapObject> result;
return d.Deserialize(isolate).ToHandle(&result)
return d.Deserialize().ToHandle(&result)
? Handle<SharedFunctionInfo>::cast(result)
: MaybeHandle<SharedFunctionInfo>();
}
......@@ -39,11 +41,9 @@ ObjectDeserializer::DeserializeSharedFunctionInfoOffThread(
UNREACHABLE();
}
MaybeHandle<HeapObject> ObjectDeserializer::Deserialize(Isolate* isolate) {
Initialize(isolate);
MaybeHandle<HeapObject> ObjectDeserializer::Deserialize() {
DCHECK(deserializing_user_code());
HandleScope scope(isolate);
HandleScope scope(isolate());
Handle<HeapObject> result;
{
result = ReadObject();
......
......@@ -23,10 +23,10 @@ class ObjectDeserializer final : public Deserializer {
Handle<String> source);
private:
explicit ObjectDeserializer(const SerializedCodeData* data);
explicit ObjectDeserializer(Isolate* isolate, const SerializedCodeData* data);
// Deserialize an object graph. Fail gracefully.
MaybeHandle<HeapObject> Deserialize(Isolate* isolate);
MaybeHandle<HeapObject> Deserialize();
void LinkAllocationSites();
void CommitPostProcessedObjects();
......
......@@ -14,25 +14,24 @@
namespace v8 {
namespace internal {
void ReadOnlyDeserializer::DeserializeInto(Isolate* isolate) {
Initialize(isolate);
HandleScope scope(isolate);
void ReadOnlyDeserializer::DeserializeIntoIsolate() {
HandleScope scope(isolate());
ReadOnlyHeap* ro_heap = isolate->read_only_heap();
ReadOnlyHeap* ro_heap = isolate()->read_only_heap();
// No active threads.
DCHECK_NULL(isolate->thread_manager()->FirstThreadStateInUse());
DCHECK_NULL(isolate()->thread_manager()->FirstThreadStateInUse());
// No active handles.
DCHECK(isolate->handle_scope_implementer()->blocks()->empty());
DCHECK(isolate()->handle_scope_implementer()->blocks()->empty());
// Read-only object cache is not yet populated.
DCHECK(!ro_heap->read_only_object_cache_is_initialized());
// Startup object cache is not yet populated.
DCHECK(isolate->startup_object_cache()->empty());
DCHECK(isolate()->startup_object_cache()->empty());
// Builtins are not yet created.
DCHECK(!isolate->builtins()->is_initialized());
DCHECK(!isolate()->builtins()->is_initialized());
{
ReadOnlyRoots roots(isolate);
ReadOnlyRoots roots(isolate());
roots.Iterate(this);
ro_heap->read_only_space()->RepairFreeSpacesAfterDeserialization();
......@@ -51,7 +50,7 @@ void ReadOnlyDeserializer::DeserializeInto(Isolate* isolate) {
}
if (FLAG_rehash_snapshot && can_rehash()) {
isolate->heap()->InitializeHashSeed();
isolate()->heap()->InitializeHashSeed();
Rehash();
}
}
......
......@@ -16,11 +16,13 @@ namespace internal {
// Read-only object cache used by the other deserializers.
class ReadOnlyDeserializer final : public Deserializer {
public:
explicit ReadOnlyDeserializer(const SnapshotData* data)
: Deserializer(data, false) {}
explicit ReadOnlyDeserializer(Isolate* isolate, const SnapshotData* data,
bool can_rehash)
: Deserializer(isolate, data->Payload(), data->GetMagicNumber(), false,
can_rehash) {}
// Deserialize the snapshot into an empty heap.
void DeserializeInto(Isolate* isolate);
void DeserializeIntoIsolate();
};
} // namespace internal
......
......@@ -158,12 +158,9 @@ bool Snapshot::Initialize(Isolate* isolate) {
SnapshotData startup_snapshot_data(MaybeDecompress(startup_data));
SnapshotData read_only_snapshot_data(MaybeDecompress(read_only_data));
StartupDeserializer startup_deserializer(&startup_snapshot_data);
ReadOnlyDeserializer read_only_deserializer(&read_only_snapshot_data);
startup_deserializer.SetRehashability(ExtractRehashability(blob));
read_only_deserializer.SetRehashability(ExtractRehashability(blob));
bool success =
isolate->InitWithSnapshot(&read_only_deserializer, &startup_deserializer);
bool success = isolate->InitWithSnapshot(&startup_snapshot_data,
&read_only_snapshot_data,
ExtractRehashability(blob));
if (FLAG_profile_deserialization) {
double ms = timer.Elapsed().InMillisecondsF();
int bytes = startup_data.length();
......
......@@ -14,32 +14,31 @@
namespace v8 {
namespace internal {
void StartupDeserializer::DeserializeInto(Isolate* isolate) {
Initialize(isolate);
HandleScope scope(isolate);
void StartupDeserializer::DeserializeIntoIsolate() {
HandleScope scope(isolate());
// No active threads.
DCHECK_NULL(isolate->thread_manager()->FirstThreadStateInUse());
DCHECK_NULL(isolate()->thread_manager()->FirstThreadStateInUse());
// No active handles.
DCHECK(isolate->handle_scope_implementer()->blocks()->empty());
DCHECK(isolate()->handle_scope_implementer()->blocks()->empty());
// Startup object cache is not yet populated.
DCHECK(isolate->startup_object_cache()->empty());
DCHECK(isolate()->startup_object_cache()->empty());
// Builtins are not yet created.
DCHECK(!isolate->builtins()->is_initialized());
DCHECK(!isolate()->builtins()->is_initialized());
{
isolate->heap()->IterateSmiRoots(this);
isolate->heap()->IterateRoots(
isolate()->heap()->IterateSmiRoots(this);
isolate()->heap()->IterateRoots(
this,
base::EnumSet<SkipRoot>{SkipRoot::kUnserializable, SkipRoot::kWeak});
Iterate(isolate, this);
Iterate(isolate(), this);
DeserializeStringTable();
isolate->heap()->IterateWeakRoots(
isolate()->heap()->IterateWeakRoots(
this, base::EnumSet<SkipRoot>{SkipRoot::kUnserializable});
DeserializeDeferredObjects();
RestoreExternalReferenceRedirectors(isolate, accessor_infos());
RestoreExternalReferenceRedirectors(isolate, call_handler_infos());
RestoreExternalReferenceRedirectors(isolate(), accessor_infos());
RestoreExternalReferenceRedirectors(isolate(), call_handler_infos());
// Flush the instruction cache for the entire code-space. Must happen after
// builtins deserialization.
......@@ -48,20 +47,20 @@ void StartupDeserializer::DeserializeInto(Isolate* isolate) {
CheckNoArrayBufferBackingStores();
isolate->heap()->set_native_contexts_list(
ReadOnlyRoots(isolate).undefined_value());
isolate()->heap()->set_native_contexts_list(
ReadOnlyRoots(isolate()).undefined_value());
// The allocation site list is build during root iteration, but if no sites
// were encountered then it needs to be initialized to undefined.
if (isolate->heap()->allocation_sites_list() == Smi::zero()) {
isolate->heap()->set_allocation_sites_list(
ReadOnlyRoots(isolate).undefined_value());
if (isolate()->heap()->allocation_sites_list() == Smi::zero()) {
isolate()->heap()->set_allocation_sites_list(
ReadOnlyRoots(isolate()).undefined_value());
}
isolate->heap()->set_dirty_js_finalization_registries_list(
ReadOnlyRoots(isolate).undefined_value());
isolate->heap()->set_dirty_js_finalization_registries_list_tail(
ReadOnlyRoots(isolate).undefined_value());
isolate()->heap()->set_dirty_js_finalization_registries_list(
ReadOnlyRoots(isolate()).undefined_value());
isolate()->heap()->set_dirty_js_finalization_registries_list_tail(
ReadOnlyRoots(isolate()).undefined_value());
isolate->builtins()->MarkInitialized();
isolate()->builtins()->MarkInitialized();
LogNewMapEvents();
WeakenDescriptorArrays();
......
......@@ -15,11 +15,14 @@ namespace internal {
// Initializes an isolate with context-independent data from a given snapshot.
class StartupDeserializer final : public Deserializer {
public:
explicit StartupDeserializer(const SnapshotData* startup_data)
: Deserializer(startup_data, false) {}
explicit StartupDeserializer(Isolate* isolate,
const SnapshotData* startup_data,
bool can_rehash)
: Deserializer(isolate, startup_data->Payload(),
startup_data->GetMagicNumber(), false, can_rehash) {}
// Deserialize the snapshot into an empty heap.
void DeserializeInto(Isolate* isolate);
void DeserializeIntoIsolate();
private:
void DeserializeStringTable();
......
......@@ -94,21 +94,19 @@ class TestSerializer {
v8::Isolate* v8_isolate = NewIsolate(kEnableSerializer, kGenerateHeap);
v8::Isolate::Scope isolate_scope(v8_isolate);
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
isolate->Init(nullptr, nullptr);
isolate->Init(nullptr, nullptr, false);
return v8_isolate;
}
static v8::Isolate* NewIsolateFromBlob(const StartupBlobs& blobs) {
SnapshotData startup_snapshot(blobs.startup);
SnapshotData read_only_snapshot(blobs.read_only);
ReadOnlyDeserializer read_only_deserializer(&read_only_snapshot);
StartupDeserializer startup_deserializer(&startup_snapshot);
const bool kEnableSerializer = false;
const bool kGenerateHeap = false;
v8::Isolate* v8_isolate = NewIsolate(kEnableSerializer, kGenerateHeap);
v8::Isolate::Scope isolate_scope(v8_isolate);
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
isolate->Init(&read_only_deserializer, &startup_deserializer);
isolate->Init(&startup_snapshot, &read_only_snapshot, false);
return v8_isolate;
}
......
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