-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
src: attach CppHeap to an v8::Isolate with isolate params #53038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,10 +25,13 @@ | |
| namespace node { | ||
|
|
||
| using v8::Context; | ||
| using v8::CppHeap; | ||
| using v8::CppHeapCreateParams; | ||
| using v8::HandleScope; | ||
| using v8::Isolate; | ||
| using v8::Local; | ||
| using v8::Locker; | ||
| using v8::WrapperDescriptor; | ||
|
|
||
| NodeMainInstance::NodeMainInstance(const SnapshotData* snapshot_data, | ||
| uv_loop_t* event_loop, | ||
|
|
@@ -38,12 +41,20 @@ NodeMainInstance::NodeMainInstance(const SnapshotData* snapshot_data, | |
| : args_(args), | ||
| exec_args_(exec_args), | ||
| array_buffer_allocator_(ArrayBufferAllocator::Create()), | ||
| cpp_heap_(CppHeap::Create( | ||
| platform, | ||
| CppHeapCreateParams{ | ||
| {}, | ||
| WrapperDescriptor(BaseObject::kEmbedderType, | ||
| BaseObject::kSlot, | ||
| BaseObject::kDefaultCppGCEmebdderTypeID)})), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How are embedders expected to get the correct values such as
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, wrapper descriptors are going to be deprecated so that embedders don't have to care about what the value is: nodejs/node-v8#283. Read more at https://docs.google.com/document/d/1-sBltmlx4yUIzmNHrRO9lKjqiN-uJ81gCmj9-Gq5d5w/edit
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, then this will 'just' attach a CppHeap with default options in the future anyway? That still feels like
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I turned this into a draft because I think the current form is not complete. |
||
| isolate_(nullptr), | ||
| platform_(platform), | ||
| isolate_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 = cpp_heap_.get(); | ||
|
|
||
| isolate_ = | ||
| NewIsolate(isolate_params_.get(), event_loop, platform, snapshot_data); | ||
|
|
@@ -83,6 +94,8 @@ NodeMainInstance::~NodeMainInstance() { | |
| isolate_data_.reset(); | ||
| platform_->UnregisterIsolate(isolate_); | ||
| } | ||
| // CppHeap is terminated by the isolate, no allocation is allowed at this | ||
| // point. | ||
| isolate_->Dispose(); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.