mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
worker: use snapshot in workers spawned by workers
Previously we didn't pass the snapshot data down to the isolate data of workers so workers spawned by workers won't use the snapshot. Fixes it by passing the snapshot data down. PR-URL: https://github.com/nodejs/node/pull/47731 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
@@ -179,10 +179,12 @@ class WorkerThreadData {
|
||||
isolate->SetStackLimit(w->stack_base_);
|
||||
|
||||
HandleScope handle_scope(isolate);
|
||||
isolate_data_.reset(CreateIsolateData(isolate,
|
||||
&loop_,
|
||||
w_->platform_,
|
||||
allocator.get()));
|
||||
isolate_data_.reset(
|
||||
CreateIsolateData(isolate,
|
||||
&loop_,
|
||||
w_->platform_,
|
||||
allocator.get(),
|
||||
w->snapshot_data()->AsEmbedderWrapper().get()));
|
||||
CHECK(isolate_data_);
|
||||
if (w_->per_isolate_opts_)
|
||||
isolate_data_->set_options(std::move(w_->per_isolate_opts_));
|
||||
@@ -315,6 +317,10 @@ void Worker::Run() {
|
||||
// though.
|
||||
TryCatch try_catch(isolate_);
|
||||
if (snapshot_data_ != nullptr) {
|
||||
Debug(this,
|
||||
"Worker %llu uses context from snapshot %d\n",
|
||||
thread_id_.id,
|
||||
static_cast<int>(SnapshotData::kNodeBaseContextIndex));
|
||||
context = Context::FromSnapshot(isolate_,
|
||||
SnapshotData::kNodeBaseContextIndex)
|
||||
.ToLocalChecked();
|
||||
@@ -323,6 +329,8 @@ void Worker::Run() {
|
||||
context = Local<Context>();
|
||||
}
|
||||
} else {
|
||||
Debug(
|
||||
this, "Worker %llu builds context from scratch\n", thread_id_.id);
|
||||
context = NewContext(isolate_);
|
||||
}
|
||||
if (context.IsEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user