-
Notifications
You must be signed in to change notification settings - Fork 30k
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
src: export InitializeV8Platform function #31217
Conversation
export InitializeV8Platform to allow use node as a shared library.
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.
LGTM
However, I would very much encourage using CreatePlatform()
/FreePlatform()
rather than using the global instance.
@addaleax Thanks for comment. I used CreatePlatform. However, the call to GetMainThreadMultiIsolatePlatform (Call from NewIsolate) used by worker_threads fails. Initialization of Lines 353 to 355 in 2bdeb88
<= node/src/node_v8_platform-inl.h Lines 83 to 99 in 2bdeb88
|
You already can with auto platform = node::CreatePlatform(thread_pool_size, some_stock_tracing_controller);
v8::V8::InitializePlatform(platform);
return platform; I don't see a good reason to export it. Can you elaborate on what it enables that you can't do with edit: comments just crossed. |
@bnoordhuis See the comments above. |
Right, so what is probably missing is an API to call (I won't block this PR but it seems like the wrong approach.) |
@jc-lab That sounds an awful lot like the bug that was fixed by 6db45bf … what version of Node.js are you using?
I’d prefer moving away from the global |
@addaleax Oops... |
I have a question about node::CreateEnvironment. Lines 301 to 322 in 2551a21
-> Lines 333 to 337 in 2551a21
-> node/src/node_v8_platform-inl.h Lines 135 to 137 in 2551a21
Here, V8Platform :: Initialize must be called for tracing_file_writer_ to be initialized when NODE_USE_V8_PLATFORM is 1. |
Codecov Report
@@ Coverage Diff @@
## master #31217 +/- ##
=========================================
Coverage ? 97.32%
=========================================
Files ? 192
Lines ? 64162
Branches ? 0
=========================================
Hits ? 62444
Misses ? 1718
Partials ? 0 Continue to review full report at Codecov.
|
This API method was introduced in commit 90ae4bd ("src: add InitializeV8Platform function") from July 2018 but wasn't properly exported and therefore not usable on Windows or with shared library builds. The motivation from the commit log is mainly about making it easier to wire up the cctests and there are better ways to do that. Refs: nodejs#31217
This requires minor changes to src/env.cc to deal with `node::tracing::AgentWriterHandle::GetTracingController()` now possibly returning a nullptr, because the cctest doesn't set one. It seems plausible to me that embedders won't set one either so that seems like an okay change to make. It avoids embedders having to track down nullptr segfaults. PR-URL: #31245 Refs: #31217 Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This API method was introduced in commit 90ae4bd ("src: add InitializeV8Platform function") from July 2018 but wasn't properly exported and therefore not usable on Windows or with shared library builds. The motivation from the commit log is mainly about making it easier to wire up the cctests and there are better ways to do that. Refs: #31217 PR-URL: #31245 Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This requires minor changes to src/env.cc to deal with `node::tracing::AgentWriterHandle::GetTracingController()` now possibly returning a nullptr, because the cctest doesn't set one. It seems plausible to me that embedders won't set one either so that seems like an okay change to make. It avoids embedders having to track down nullptr segfaults. PR-URL: #31245 Refs: #31217 Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This API method was introduced in commit 90ae4bd ("src: add InitializeV8Platform function") from July 2018 but wasn't properly exported and therefore not usable on Windows or with shared library builds. The motivation from the commit log is mainly about making it easier to wire up the cctests and there are better ways to do that. Refs: #31217 PR-URL: #31245 Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This requires minor changes to src/env.cc to deal with `node::tracing::AgentWriterHandle::GetTracingController()` now possibly returning a nullptr, because the cctest doesn't set one. It seems plausible to me that embedders won't set one either so that seems like an okay change to make. It avoids embedders having to track down nullptr segfaults. PR-URL: #31245 Refs: #31217 Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This API method was introduced in commit 90ae4bd ("src: add InitializeV8Platform function") from July 2018 but wasn't properly exported and therefore not usable on Windows or with shared library builds. The motivation from the commit log is mainly about making it easier to wire up the cctests and there are better ways to do that. Refs: #31217 PR-URL: #31245 Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Export InitializeV8Platform to allow use node as a shared library.
For example:
https://github.com/jc-lab/node-app
make -j4 test
(UNIX), orvcbuild test
(Windows) passes