Skip to content

Commit

Permalink
Provide CppHeap for Isolate initialization
Browse files Browse the repository at this point in the history
Isolate::AttachCppHeap is about to be deprecated soon, the CppHeap
should be provided during Isolate initialization instead.
  • Loading branch information
gahaas committed Jan 29, 2025
1 parent b8204b6 commit 24078f4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -580,13 +580,6 @@ IsolateData::IsolateData(Isolate* isolate,
// We do not care about overflow since we just want this to be different
// from the cppgc id.
uint16_t non_cppgc_id = cppgc_id + 1;
if (cpp_heap == nullptr) {
cpp_heap_ = CppHeap::Create(platform, v8::CppHeapCreateParams{{}});
// TODO(joyeecheung): pass it into v8::Isolate::CreateParams and let V8
// own it when we can keep the isolate registered/task runner discoverable
// during isolate disposal.
isolate->AttachCppHeap(cpp_heap_.get());
}

{
// GC could still be run after the IsolateData is destroyed, so we store
Expand Down
2 changes: 2 additions & 0 deletions src/node_main_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ NodeMainInstance::NodeMainInstance(const SnapshotData* snapshot_data,
isolate_params_(std::make_unique<Isolate::CreateParams>()),
snapshot_data_(snapshot_data) {
isolate_params_->array_buffer_allocator = array_buffer_allocator_.get();
isolate_params_->cpp_heap =
v8::CppHeap::Create(platform_, v8::CppHeapCreateParams{{}}).release();

isolate_ =
NewIsolate(isolate_params_.get(), event_loop, platform, snapshot_data);
Expand Down
3 changes: 3 additions & 0 deletions src/node_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ class WorkerThreadData {
SetIsolateCreateParamsForNode(&params);
w->UpdateResourceConstraints(&params.constraints);
params.array_buffer_allocator_shared = allocator;
params.cpp_heap =
v8::CppHeap::Create(w->platform_, v8::CppHeapCreateParams{{}})
.release();
Isolate* isolate =
NewIsolate(&params, &loop_, w->platform_, w->snapshot_data());
if (isolate == nullptr) {
Expand Down

0 comments on commit 24078f4

Please sign in to comment.