Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,13 @@ Isolate* NewIsolate(ArrayBufferAllocator* allocator,
uv_loop_t* event_loop,
MultiIsolatePlatform* platform,
const EmbedderSnapshotData* snapshot_data,
const IsolateSettings& settings) {
const IsolateSettings& settings,
std::unique_ptr<v8::CppHeap> cpp_heap) {
Isolate::CreateParams params;
if (allocator != nullptr) params.array_buffer_allocator = allocator;
if (cpp_heap) {
params.cpp_heap = cpp_heap.release();
}
return NewIsolate(&params,
event_loop,
platform,
Expand Down
3 changes: 2 additions & 1 deletion src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,8 @@ NODE_EXTERN v8::Isolate* NewIsolate(
struct uv_loop_s* event_loop,
MultiIsolatePlatform* platform,
const EmbedderSnapshotData* snapshot_data = nullptr,
const IsolateSettings& settings = {});
const IsolateSettings& settings = {},
std::unique_ptr<v8::CppHeap> cpp_heap = {});
NODE_EXTERN v8::Isolate* NewIsolate(
std::shared_ptr<ArrayBufferAllocator> allocator,
struct uv_loop_s* event_loop,
Expand Down
12 changes: 3 additions & 9 deletions test/cctest/test_cppgc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,14 @@ int CppGCed::kDestructCount = 0;
int CppGCed::kTraceCount = 0;

TEST_F(NodeZeroIsolateTestFixture, ExistingCppHeapTest) {
v8::Isolate* isolate =
node::NewIsolate(allocator.get(), &current_loop, platform.get());

// Create and attach the CppHeap before we set up the IsolateData so that
// it recognizes the existing heap.
std::unique_ptr<v8::CppHeap> cpp_heap =
v8::CppHeap::Create(platform.get(), 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());
v8::Isolate* isolate =
node::NewIsolate(allocator.get(), &current_loop, platform.get(),
nullptr, {}, std::move(cpp_heap));

// Try creating Context + IsolateData + Environment.
{
Expand Down Expand Up @@ -102,8 +98,6 @@ TEST_F(NodeZeroIsolateTestFixture, ExistingCppHeapTest) {
platform->DrainTasks(isolate);

// Cleanup.
isolate->DetachCppHeap();
cpp_heap->Terminate();
platform->DrainTasks(isolate);
}

Expand Down
Loading