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:
parent
62b2cf30f2
commit
f6f1131096
@ -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, ¶ms);
|
||||
}
|
||||
params.array_buffer_allocator = allocator_.get();
|
||||
Isolate::Initialize(isolate_, params);
|
||||
}
|
||||
|
@ -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_; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user