src: support snapshot deserialization in RAIIIsolate

PR-URL: https://github.com/nodejs/node/pull/49226
Refs: https://github.com/nodejs/node-v8/issues/252
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
This commit is contained in:
Joyee Cheung 2023-08-18 14:33:54 +02:00 committed by Node.js GitHub Bot
parent 62b2cf30f2
commit f6f1131096
2 changed files with 6 additions and 2 deletions

View File

@ -27,6 +27,7 @@
#include "node_buffer.h"
#include "node_errors.h"
#include "node_internals.h"
#include "node_snapshot_builder.h"
#include "node_v8_platform-inl.h"
#include "string_bytes.h"
#include "uv.h"
@ -677,13 +678,16 @@ Local<String> UnionBytes::ToStringChecked(Isolate* isolate) const {
}
}
RAIIIsolate::RAIIIsolate()
RAIIIsolate::RAIIIsolate(const SnapshotData* data)
: allocator_{ArrayBuffer::Allocator::NewDefaultAllocator()} {
isolate_ = Isolate::Allocate();
CHECK_NOT_NULL(isolate_);
per_process::v8_platform.Platform()->RegisterIsolate(isolate_,
uv_default_loop());
Isolate::CreateParams params;
if (data != nullptr) {
SnapshotBuilder::InitializeIsolateParams(data, &params);
}
params.array_buffer_allocator = allocator_.get();
Isolate::Initialize(isolate_, params);
}

View File

@ -971,7 +971,7 @@ void SetConstructorFunction(v8::Isolate* isolate,
// Simple RAII class to spin up a v8::Isolate instance.
class RAIIIsolate {
public:
RAIIIsolate();
explicit RAIIIsolate(const SnapshotData* data = nullptr);
~RAIIIsolate();
v8::Isolate* get() const { return isolate_; }