Skip to content

Commit

Permalink
Always create a CppHeap at isolate creation
Browse files Browse the repository at this point in the history
With the new V8 API, the CppHeap should be provided during Isolate
initialization.
  • Loading branch information
gahaas committed Jan 31, 2025
1 parent 068c63f commit fdc0cc8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ Isolate* NewIsolate(Isolate::CreateParams* params,
MultiIsolatePlatform* platform,
const SnapshotData* snapshot_data,
const IsolateSettings& settings) {
if (params->cpp_heap == nullptr) {
params->cpp_heap =
v8::CppHeap::Create(platform, v8::CppHeapCreateParams{{}}).release();
}
Isolate* isolate = Isolate::Allocate();
if (isolate == nullptr) return nullptr;

Expand Down
3 changes: 3 additions & 0 deletions test/cctest/test_environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,9 @@ TEST_F(NodeZeroIsolateTestFixture, CtrlCWithOnlySafeTerminationTest) {
// Allocate and initialize Isolate.
v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = allocator.get();
create_params.cpp_heap =
v8::CppHeap::Create(platform.get(), v8::CppHeapCreateParams{{}})
.release();
v8::Isolate* isolate = v8::Isolate::Allocate();
CHECK_NOT_NULL(isolate);
platform->RegisterIsolate(isolate, &current_loop);
Expand Down

0 comments on commit fdc0cc8

Please sign in to comment.