Skip to content
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: various improvements toward a complete embedder API #30229

Closed
wants to merge 6 commits into from

Conversation

@addaleax
Copy link
Member

addaleax commented Nov 2, 2019

These changes should help make embedding easier, by
requiring fewer internal methods to build a fully functioning
Node.js instance.

The first commit is #30228. (Marking this as blocked until that lands.)

src: track no of active JS signal handlers

This makes it possible to tell whether a signal is being tracked in JS.

src: make EndStartedProfilers an exit hook

Run EndStartedProfilers on Environment teardown.

src: make WaitForInspectorDisconnect an exit hook

Run inspector cleanup code on Environment teardown.

src: use unique_ptr for InitializeInspector()

This makes more sense than releasing and re-wrapping the raw pointer.

src: run RunBeforeExitCallbacks as part of EmitBeforeExit

This also aligns the worker_threads code with the main thread code.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
@addaleax addaleax requested a review from codebytere Nov 2, 2019
@addaleax addaleax added the embedding label Nov 2, 2019
@addaleax addaleax requested a review from joyeecheung Nov 2, 2019
@addaleax addaleax added the blocked label Nov 3, 2019
@cjihrig
cjihrig approved these changes Nov 5, 2019
addaleax added 5 commits Nov 2, 2019
This makes it possible to tell whether a signal is being tracked in JS.
Run `EndStartedProfilers` on Environment teardown.

This is part of a series of changes to make embedding easier, by
requiring fewer internal methods to build a fully functioning
Node.js instance.
Run inspector cleanup code on Environment teardown.

This is part of a series of changes to make embedding easier, by
requiring fewer internal methods to build a fully functioning
Node.js instance.
This makes more sense than releasing and re-wrapping the raw pointer.
This is part of a series of changes to make embedding easier, by
requiring fewer internal methods to build a fully functioning
Node.js instance.

This also aligns the worker_threads code with the main thread code.
@addaleax addaleax force-pushed the addaleax:embedding-improvements branch from 7bf8cdf to 36787d7 Nov 5, 2019
@nodejs-github-bot

This comment has been minimized.

Copy link

nodejs-github-bot commented Nov 5, 2019

@addaleax addaleax requested a review from gireeshpunathil Nov 6, 2019
src/signal_wrap.cc Show resolved Hide resolved
src/signal_wrap.cc Outdated Show resolved Hide resolved
src/node_internals.h Show resolved Hide resolved
@addaleax addaleax removed the review wanted label Nov 6, 2019
@nodejs-github-bot

This comment has been minimized.

Copy link
Member

joyeecheung left a comment

Much better to do this in the exit hooks than to do this in ad-hoc places during the shutdown path!

}
}
if (try_catch.HasCaught() && !try_catch.HasTerminated()) {
PrintCaughtException(isolate, context, try_catch);

This comment has been minimized.

Copy link
@joyeecheung

joyeecheung Nov 6, 2019

Member

Not really related to this PR but now come to think of it we should probably avoid executing JS at all during profile serialization considering we also write the profiles when there is an uncaught exception...

This comment has been minimized.

Copy link
@addaleax

addaleax Nov 6, 2019

Author Member

@joyeecheung Yeah … I had the same thought, and I talked about it with @bcoe – it turns out re-implementing the JS code in C++ expands the code quite noticeably, and moving the source map caches to C++ is also tricky, in part because the CJS cache relies on Module._cache and we probably don’t want to move that to C++… if you have a better solution for this, feel free to PR that 😅

@@ -778,6 +778,13 @@ bool Agent::Start(const std::string& path,
StartDebugSignalHandler();
}

AtExit(parent_env_, [](void* env) {

This comment has been minimized.

Copy link
@joyeecheung

joyeecheung Nov 6, 2019

Member

IIUC this is the first time we use AtExit internally? (I vaguely remember we have done that before but I could not find any existing AtExit calls ATM)

This comment has been minimized.

Copy link
@addaleax

addaleax Nov 6, 2019

Author Member

Yes, I think so 👍

Copy link
Member

codebytere left a comment

also looks good to me generally!

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

addaleax added a commit that referenced this pull request Nov 6, 2019
This makes it possible to tell whether a signal is being tracked in JS.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
addaleax added a commit that referenced this pull request Nov 6, 2019
Run `EndStartedProfilers` on Environment teardown.

This is part of a series of changes to make embedding easier, by
requiring fewer internal methods to build a fully functioning
Node.js instance.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
addaleax added a commit that referenced this pull request Nov 6, 2019
Run inspector cleanup code on Environment teardown.

This is part of a series of changes to make embedding easier, by
requiring fewer internal methods to build a fully functioning
Node.js instance.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
addaleax added a commit that referenced this pull request Nov 6, 2019
This makes more sense than releasing and re-wrapping the raw pointer.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
addaleax added a commit that referenced this pull request Nov 6, 2019
This is part of a series of changes to make embedding easier, by
requiring fewer internal methods to build a fully functioning
Node.js instance.

This also aligns the worker_threads code with the main thread code.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
@addaleax

This comment has been minimized.

Copy link
Member Author

addaleax commented Nov 6, 2019

Landed in 4aca277...d4b2cc7, thanks for the reviews!

@addaleax addaleax closed this Nov 6, 2019
@addaleax addaleax deleted the addaleax:embedding-improvements branch Nov 6, 2019
MylesBorins added a commit that referenced this pull request Nov 17, 2019
This makes it possible to tell whether a signal is being tracked in JS.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
MylesBorins added a commit that referenced this pull request Nov 17, 2019
Run `EndStartedProfilers` on Environment teardown.

This is part of a series of changes to make embedding easier, by
requiring fewer internal methods to build a fully functioning
Node.js instance.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
MylesBorins added a commit that referenced this pull request Nov 17, 2019
Run inspector cleanup code on Environment teardown.

This is part of a series of changes to make embedding easier, by
requiring fewer internal methods to build a fully functioning
Node.js instance.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
MylesBorins added a commit that referenced this pull request Nov 17, 2019
This makes more sense than releasing and re-wrapping the raw pointer.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
MylesBorins added a commit that referenced this pull request Nov 17, 2019
This is part of a series of changes to make embedding easier, by
requiring fewer internal methods to build a fully functioning
Node.js instance.

This also aligns the worker_threads code with the main thread code.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
@BridgeAR BridgeAR mentioned this pull request Nov 19, 2019
targos added a commit that referenced this pull request Dec 1, 2019
This makes it possible to tell whether a signal is being tracked in JS.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
targos added a commit that referenced this pull request Dec 1, 2019
Run `EndStartedProfilers` on Environment teardown.

This is part of a series of changes to make embedding easier, by
requiring fewer internal methods to build a fully functioning
Node.js instance.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
targos added a commit that referenced this pull request Dec 1, 2019
Run inspector cleanup code on Environment teardown.

This is part of a series of changes to make embedding easier, by
requiring fewer internal methods to build a fully functioning
Node.js instance.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
targos added a commit that referenced this pull request Dec 1, 2019
This makes more sense than releasing and re-wrapping the raw pointer.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
targos added a commit that referenced this pull request Dec 1, 2019
This is part of a series of changes to make embedding easier, by
requiring fewer internal methods to build a fully functioning
Node.js instance.

This also aligns the worker_threads code with the main thread code.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
@BethGriggs BethGriggs mentioned this pull request Dec 9, 2019
MylesBorins added a commit that referenced this pull request Dec 17, 2019
This makes it possible to tell whether a signal is being tracked in JS.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
MylesBorins added a commit that referenced this pull request Dec 17, 2019
Run `EndStartedProfilers` on Environment teardown.

This is part of a series of changes to make embedding easier, by
requiring fewer internal methods to build a fully functioning
Node.js instance.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
MylesBorins added a commit that referenced this pull request Dec 17, 2019
Run inspector cleanup code on Environment teardown.

This is part of a series of changes to make embedding easier, by
requiring fewer internal methods to build a fully functioning
Node.js instance.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
MylesBorins added a commit that referenced this pull request Dec 17, 2019
This makes more sense than releasing and re-wrapping the raw pointer.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
MylesBorins added a commit that referenced this pull request Dec 17, 2019
This is part of a series of changes to make embedding easier, by
requiring fewer internal methods to build a fully functioning
Node.js instance.

This also aligns the worker_threads code with the main thread code.

PR-URL: #30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
@BethGriggs BethGriggs mentioned this pull request Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.