Skip to content

Commit

Permalink
src: support snapshot deserialization in RAIIIsolate
Browse files Browse the repository at this point in the history
PR-URL: #49226
Refs: nodejs/node-v8#252
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
  • Loading branch information
joyeecheung authored and UlisesGascon committed Sep 10, 2023
1 parent a22e0d9 commit 55d6649
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_; }
Expand Down

0 comments on commit 55d6649

Please sign in to comment.