Skip to content

Commit 24078f4

Browse files
committed
Provide CppHeap for Isolate initialization
Isolate::AttachCppHeap is about to be deprecated soon, the CppHeap should be provided during Isolate initialization instead.
1 parent b8204b6 commit 24078f4

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

src/env.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -580,13 +580,6 @@ IsolateData::IsolateData(Isolate* isolate,
580580
// We do not care about overflow since we just want this to be different
581581
// from the cppgc id.
582582
uint16_t non_cppgc_id = cppgc_id + 1;
583-
if (cpp_heap == nullptr) {
584-
cpp_heap_ = CppHeap::Create(platform, v8::CppHeapCreateParams{{}});
585-
// TODO(joyeecheung): pass it into v8::Isolate::CreateParams and let V8
586-
// own it when we can keep the isolate registered/task runner discoverable
587-
// during isolate disposal.
588-
isolate->AttachCppHeap(cpp_heap_.get());
589-
}
590583

591584
{
592585
// GC could still be run after the IsolateData is destroyed, so we store

src/node_main_instance.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ NodeMainInstance::NodeMainInstance(const SnapshotData* snapshot_data,
4444
isolate_params_(std::make_unique<Isolate::CreateParams>()),
4545
snapshot_data_(snapshot_data) {
4646
isolate_params_->array_buffer_allocator = array_buffer_allocator_.get();
47+
isolate_params_->cpp_heap =
48+
v8::CppHeap::Create(platform_, v8::CppHeapCreateParams{{}}).release();
4749

4850
isolate_ =
4951
NewIsolate(isolate_params_.get(), event_loop, platform, snapshot_data);

src/node_worker.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ class WorkerThreadData {
162162
SetIsolateCreateParamsForNode(&params);
163163
w->UpdateResourceConstraints(&params.constraints);
164164
params.array_buffer_allocator_shared = allocator;
165+
params.cpp_heap =
166+
v8::CppHeap::Create(w->platform_, v8::CppHeapCreateParams{{}})
167+
.release();
165168
Isolate* isolate =
166169
NewIsolate(&params, &loop_, w->platform_, w->snapshot_data());
167170
if (isolate == nullptr) {

0 commit comments

Comments
 (0)