-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
[v12.x backport] src: improve embedder API #35241
Commits on Sep 23, 2020
-
src: make
FreeEnvironment()
perform all necessary cleanupMake the calls `stop_sub_worker_contexts()`, `RunCleanup()` part of the public API for easier embedding. (Note that calling `RunAtExit()` is idempotent because the at-exit callback queue is cleared after each call.) PR-URL: nodejs#30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for ebdf84a - Browse repository at this point
Copy the full SHA ebdf84aView commit details -
src: fix memory leak in CreateEnvironment when bootstrap fails
PR-URL: nodejs#30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 3f9fa28 - Browse repository at this point
Copy the full SHA 3f9fa28View commit details -
src: move worker_context from Environment to IsolateData
Workers are fully in control of their Isolates, and this helps avoid a problem with later changes to `CreateEnvironment()` because now we can run the boostrapping code inside the latter. PR-URL: nodejs#30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 459973c - Browse repository at this point
Copy the full SHA 459973cView commit details -
src: associate is_main_thread() with worker_context()
In our codebase, the assumption generally is that `!is_main_thread()` means that the current Environment belongs to a Node.js Worker thread. PR-URL: nodejs#30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 2c87b17 - Browse repository at this point
Copy the full SHA 2c87b17View commit details -
src: align worker and main thread code with embedder API
This addresses some long-standing TODOs by Joyee and me about making the embedder API more powerful and us less reliant on internal APIs for creating the main thread and Workers. PR-URL: nodejs#30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 0e9f4a9 - Browse repository at this point
Copy the full SHA 0e9f4a9View commit details -
src: provide a variant of LoadEnvironment taking a callback
This allows embedders to flexibly control how they start JS code rather than using `third_party_main`. PR-URL: nodejs#30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for c694f08 - Browse repository at this point
Copy the full SHA c694f08View commit details -
src: add LoadEnvironment() variant taking a string
Allow passing a string as the main module rather than using the callback variant. PR-URL: nodejs#30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 8a1255c - Browse repository at this point
Copy the full SHA 8a1255cView commit details -
test: re-enable cctest that was commented out
Refs: nodejs#31910 PR-URL: nodejs#30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for bb689cf - Browse repository at this point
Copy the full SHA bb689cfView commit details -
src: add unique_ptr equivalent of CreatePlatform
This makes this bit of the embedder situation a bit easier to use. PR-URL: nodejs#30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for ad95b85 - Browse repository at this point
Copy the full SHA ad95b85View commit details -
src: make InitializeNodeWithArgs() official public API
This is a decent replacement for the to-be-deprecated Init() API. PR-URL: nodejs#30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 33ecd3b - Browse repository at this point
Copy the full SHA 33ecd3bView commit details -
src: add ability to look up platform based on
Environment*
This should eventually remove any necessity to use the global-state `GetMainThreadMultiIsolatePlatform()`. PR-URL: nodejs#30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 31528f3 - Browse repository at this point
Copy the full SHA 31528f3View commit details -
src: allow non-Node.js TracingControllers
We do not need a Node.js-provided `v8::TracingController`, generally. Loosen that restriction in order to make it easier for embedders to provide their own subclass of `v8::TracingController`, or none at all. Refs: electron/electron@9c36576 PR-URL: nodejs#30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for eca25d0 - Browse repository at this point
Copy the full SHA eca25d0View commit details -
src: fix what a dispose without checking
If created platform with CreatePlatform, the crash occurs because it does not check if it was initialized to v8_platform when DisposePlatform was called. Refs: nodejs#31260 Co-authored-by: Anna Henningsen <[email protected]> PR-URL: nodejs#30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 691a575 - Browse repository at this point
Copy the full SHA 691a575View commit details -
src: shutdown platform from FreePlatform()
There is currently no way to properly do this. PR-URL: nodejs#30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 1c5d55a - Browse repository at this point
Copy the full SHA 1c5d55aView commit details -
src,test: add full-featured embedder API test
PR-URL: nodejs#30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for a02c5d0 - Browse repository at this point
Copy the full SHA a02c5d0View commit details -
doc: add basic embedding example documentation
PR-URL: nodejs#30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 0547551 - Browse repository at this point
Copy the full SHA 0547551View commit details -
test: add extended embedder cctest
Add an embedder cctest that also covers a multi-Environment situation, including worker_threads-style inspector support. Co-authored-by: Joyee Cheung <[email protected]> PR-URL: nodejs#30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for a7ada43 - Browse repository at this point
Copy the full SHA a7ada43View commit details -
test: wait for message from parent in embedding cctest
I’ve seen this fail a few times in CI, presumably because the inspector commmand did not reach the child thread in time. Explicitly waiting seems to solve that. Refs: nodejs#30467 PR-URL: nodejs#32563 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 1a8e9ee - Browse repository at this point
Copy the full SHA 1a8e9eeView commit details -
embedding: provide hook for custom process.exit() behaviour
Embedders may not want to terminate the process when `process.exit()` is called. This provides a hook for more flexible handling of that situation. Refs: nodejs#30467 (comment) PR-URL: nodejs#32531 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: James M Snell <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 6d231db - Browse repository at this point
Copy the full SHA 6d231dbView commit details -
embedding: make Stop() stop Workers
This makes sense given that terminating execution of the parent thread this way likely also is supposed to stop all running Worker threads spawned by it. PR-URL: nodejs#32531 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: James M Snell <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 93a23b9 - Browse repository at this point
Copy the full SHA 93a23b9View commit details -
test: use InitializeNodeWithArgs in cctest
Refs: nodejs@d7f1107 Fixes: nodejs#30257 PR-URL: nodejs#32406 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 72f42bf - Browse repository at this point
Copy the full SHA 72f42bfView commit details -
test: use common.buildType in embedding test
This un-breaks testing in the case of `./configure --debug-node`. PR-URL: nodejs#32422 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for b931e68 - Browse repository at this point
Copy the full SHA b931e68View commit details -
src: initialize inspector before RunBootstrapping()
This is necessary for `--inspect-brk-node` to work, and for the inspector to be aware of scripts created before bootstrapping. Fixes: nodejs#32648 Refs: nodejs#30467 (comment) PR-URL: nodejs#32672 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Eugene Ostroukhov <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 9aa4cbe - Browse repository at this point
Copy the full SHA 9aa4cbeView commit details -
worker: unify custom error creation
Mostly, this introduces a pattern that makes sure that if a custom error is reported, `stopped_` will be set to `true` correctly in every cast, which was previously missing for the `NewContext().IsEmpty()` case (which led to a hard crash from the `Worker` destructor). This also leaves TODO comments for a few cases in which `ERR_WORKER_OUT_OF_MEMORY` was not used in accordance with the documentation for that error code (or according to its intention). Fixing that is semver-major. PR-URL: nodejs#33084 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 0a2f5e9 - Browse repository at this point
Copy the full SHA 0a2f5e9View commit details -
Configuration menu - View commit details
-
Copy full SHA for b910fc6 - Browse repository at this point
Copy the full SHA b910fc6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1ee495d - Browse repository at this point
Copy the full SHA 1ee495dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 30b6c2f - Browse repository at this point
Copy the full SHA 30b6c2fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6e63159 - Browse repository at this point
Copy the full SHA 6e63159View commit details -
src: make
Environment::interrupt_data_
atomicOtherwise this potentially leads to race conditions when used in a multi-threaded environment (i.e. when used for its very purpose). PR-URL: nodejs#32523 Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: James M Snell <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 8f464fe - Browse repository at this point
Copy the full SHA 8f464feView commit details -
src: fix cleanup hook removal for InspectorTimer
Fix this to account for the fact that `Stop()` may already have been called from a cleanup hook when the `inspector::Agent` is deleted along with the `Environment`, at which point cleanup hooks are no longer available. PR-URL: nodejs#32523 Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: James M Snell <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for a74f870 - Browse repository at this point
Copy the full SHA a74f870View commit details -
src: use env->RequestInterrupt() for inspector io thread start
This cleans up `Agent::RequestIoThreadStart()` significantly. PR-URL: nodejs#32523 Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: James M Snell <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for a2ebe11 - Browse repository at this point
Copy the full SHA a2ebe11View commit details -
src: use env->RequestInterrupt() for inspector MainThreadInterface
This simplifies the code significantly, and removes the dependency of the inspector code on the availability of a `MultiIsolatePlatform` (by removing the dependency on a platform altogether). It also fixes a memory leak that occurs when `RequestInterrupt()` is used, but the interrupt handler is never called before the Isolate is destroyed. One downside is that this leads to a slight change in timing, because inspector messages are not dispatched in a re-entrant way. This means having to harden one test to account for that possibility by making sure that the stack is always clear through a `setImmediate()`. This does not affect the assertion made by the test, which is that messages will not be delivered synchronously while other code is executing. nodejs#32415 PR-URL: nodejs#32523 Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: James M Snell <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 83015b0 - Browse repository at this point
Copy the full SHA 83015b0View commit details -
src: flush V8 interrupts from Environment dtor
This avoids an edge-case memory leak. Refs: nodejs#32523 (comment) PR-URL: nodejs#32523 Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: James M Snell <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 2b0315f - Browse repository at this point
Copy the full SHA 2b0315fView commit details -
src: add callback scope for native immediates
This ensures that microtasks scheduled by native immediates are run after the tasks are done. In particular, this affects the inspector integration since 6f9f546. Fixes: nodejs#33002 Refs: nodejs#32523 PR-URL: nodejs#34366 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: James M Snell <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for aa3e118 - Browse repository at this point
Copy the full SHA aa3e118View commit details -
Configuration menu - View commit details
-
Copy full SHA for c386bd1 - Browse repository at this point
Copy the full SHA c386bd1View commit details -
Configuration menu - View commit details
-
Copy full SHA for b7f9f3d - Browse repository at this point
Copy the full SHA b7f9f3dView commit details -
test,doc: add missing uv_setup_args() calls
libuv 1.39.0 will begin requiring uv_setup_args() to be called before attempting to access the process title. This commit adds uv_setup_args() calls that were missing in order for the test suite to pass (and updates the documentation). PR-URL: nodejs#34751 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for fa4439d - Browse repository at this point
Copy the full SHA fa4439dView commit details