Skip to content

Commit

Permalink
src: use Isolate::Free()
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung committed May 30, 2024
1 parent 128ffd5 commit 4176cef
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
11 changes: 6 additions & 5 deletions src/api/embed_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,15 @@ CommonEnvironmentSetup::~CommonEnvironmentSetup() {
}

bool platform_finished = false;
impl_->platform->AddIsolateFinishedCallback(isolate, [](void* data) {
*static_cast<bool*>(data) = true;
}, &platform_finished);
impl_->platform->AddIsolateFinishedCallback(
isolate,
[](void* data) { *static_cast<bool*>(data) = true; },
&platform_finished);
if (impl_->snapshot_creator.has_value())
impl_->snapshot_creator.reset();
else
isolate->Dispose();
isolate->Dispose(Isolate::IsolateDisposeFlags::kDontFree);
impl_->platform->UnregisterIsolate(isolate);
Isolate::Free(isolate);

// Wait until the platform has cleaned up all relevant resources.
while (!platform_finished)
Expand Down
7 changes: 4 additions & 3 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -1563,9 +1563,10 @@ void RegisterSignalHandler(int signal,
bool reset_handler = false);
#endif // _WIN32

// This is kept as a compatibility layer for addons to wrap cppgc-managed objects
// on Node.js versions without v8::Object::Wrap(). Addons created to work with
// only Node.js versions with v8::Object::Wrap() should use that instead.
// This is kept as a compatibility layer for addons to wrap cppgc-managed
// objects on Node.js versions without v8::Object::Wrap(). Addons created to
// work with only Node.js versions with v8::Object::Wrap() should use that
// instead.
NODE_DEPRECATED("Use v8::Object::Wrap()",
NODE_EXTERN void SetCppgcReference(v8::Isolate* isolate,
v8::Local<v8::Object> object,
Expand Down
3 changes: 2 additions & 1 deletion src/node_main_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ NodeMainInstance::~NodeMainInstance() {
// This should only be done on a main instance that owns its isolate.
// IsolateData must be freed before UnregisterIsolate() is called.
isolate_data_.reset();
isolate_->Dispose();
isolate_->Dispose(Isolate::IsolateDisposeFlags::kDontFree);
platform_->UnregisterIsolate(isolate_);
Isolate::Free(isolate_);
// TODO(joyeecheung): split Isolate::Free() here?
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/node_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,9 @@ class WorkerThreadData {
// new Isolate at the same address can successfully be registered with
// the platform.
// (Refs: https://github.com/nodejs/node/issues/30846)
isolate->Dispose();
isolate->Dispose(Isolate::IsolateDisposeFlags::kDontFree);
w_->platform_->UnregisterIsolate(isolate);
Isolate::Free(isolate);

// Wait until the platform has cleaned up all relevant resources.
while (!platform_finished) {
Expand Down
3 changes: 2 additions & 1 deletion src/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -724,8 +724,9 @@ RAIIIsolateWithoutEntering::RAIIIsolateWithoutEntering(const SnapshotData* data)
}

RAIIIsolateWithoutEntering::~RAIIIsolateWithoutEntering() {
isolate_->Dispose();
isolate_->Dispose(Isolate::IsolateDisposeFlags::kDontFree);
per_process::v8_platform.Platform()->UnregisterIsolate(isolate_);
Isolate::Free(isolate_);
}

RAIIIsolate::RAIIIsolate(const SnapshotData* data)
Expand Down

0 comments on commit 4176cef

Please sign in to comment.