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

[v8.x] async_hooks: C++ Embedder API overhaul #14109

Closed

Conversation

addaleax
Copy link
Member

@addaleax addaleax commented Jul 6, 2017

Backporting #14040, the first commit is a clean cherry-pick (but should be squashed together with its friend).

/cc @nodejs/async_hooks and in particular @AndreasMadsen

@addaleax addaleax added addons Issues and PRs related to native addons. async_hooks Issues and PRs related to the async hooks subsystem. c++ Issues and PRs that require attention from people who are familiar with C++. v8.x labels Jul 6, 2017
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. v8.x labels Jul 6, 2017
@addaleax addaleax added the semver-minor PRs that contain new features and should be released in the next minor version. label Jul 6, 2017
@refack
Copy link
Contributor

refack commented Jul 6, 2017

I would love to see just the squashed tests be run on v8.1.3...
So I'm thinking of a way to "retroactively" (metaphorically) add the tests to before the change. Maybe by splitting the two commits to code & tests, then squash the tests and rebase so they are the first commit (or even a separate PR).
But I'm not sure it worth messing up the commits.

@addaleax
Copy link
Member Author

addaleax commented Jul 6, 2017

I would love to see just the squashed tests be run on v8.1.3...

I mean, it’s not like you can’t do that already. I’ll try if I find the time, but you know, you have the same tools in front of me that I have ;)

@refack
Copy link
Contributor

refack commented Jul 6, 2017

I would love to see just the squashed tests be run on v8.1.3...

I mean, it’s not like you can’t do that already. I’ll try if I find the time, but you know, you have the same tools in front of me that I have ;)

Yes, also I assume they pass, I'm more thinking out loud about adding a regression test ad-hoc...
I'd be happy to do it if we agree it's worth messing with the commit order (since b14a1af424b0d4cc4ff3c9077f3eb70f73ee9d03 lands smoothly) ⚖️

@AndreasMadsen
Copy link
Member

I would love to see just the squashed tests be run on v8.1.3...

Besides containing some API changes, this also contains an important fix to AsyncHooksGetTriggerAsyncId so the tests won't pass.


namespace node {

MaybeLocal<Value> MakeCallback(Isolate* isolate,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these not in node.cc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No particular reason, except maybe that it kind of belongs to the rest of the legacy code here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All MakeCallback functions are in node.cc including the legacy ones. But since this won't land in master I don't care that much.

// Undo the Node-8.x-only alias from node.h
#undef EmitAsyncInit

async_uid EmitAsyncInit(Isolate* isolate,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not be async_id? Not that it really matters.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe? I can change it if you like. 😄

void EmitAsyncInit(const FunctionCallbackInfo<Value>& args) {
assert(args[0]->IsObject());
node::async_uid uid =
node::EmitAsyncInit(args.GetIsolate(), args[0].As<Object>(), "foobar");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The EmitAsyncInit that returns async_id requires 4 parameters, correct? Or is this a test for the async_context casting?

Also, is node::async_uid by purpose?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The EmitAsyncInit that returns async_id requires 4 parameters, correct? Or is this a test for the async_context casting?

Yes, the latter. The old one is not really exposed through our API anymore, it’s just the symbol that has to keep being exported so already-compiled libraries can reference it.

Also, is node::async_uid by purpose?

Yes, everywhere else in the tests we use async_id now, so there should be one place where we don’t.

Copy link
Member

@AndreasMadsen AndreasMadsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I have a few questions but I think it is correct.

I don't have skills to review the ABI stuff, someone else should do that. The logic itself looks fine.

src/node.h Outdated
// Legacy, Node 8.x only.

NODE_EXTERN
v8::MaybeLocal<v8::Value> MakeCallback(v8::Isolate* isolate,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not deprecate these too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks for pointing that out.

AndreasMadsen and others added 3 commits July 11, 2017 20:05
* Fix AsyncHooksGetTriggerAsyncId such it corresponds to
async_hooks.triggerAsyncId and not async_hooks.initTriggerId.
* Use an async_context struct instead of two async_uid values.
  This change was necessary since the fixing
  AsyncHooksGetTriggerAsyncId otherwise makes it impossible to
  get the correct default trigger id. It also prevents an invalid
  triggerAsyncId in MakeCallback.
* Rename async_uid to async_id for consistency
* Rename get_uid to get_async_id
* Add get_trigger_async_id to AsyncResource class

PR-URL: nodejs#14040
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@addaleax addaleax force-pushed the v8.x-async-wrap-cpp-overhaul branch from 3409631 to a2f61c4 Compare July 11, 2017 18:05
@addaleax
Copy link
Member Author

addaleax pushed a commit that referenced this pull request Jul 12, 2017
* Fix AsyncHooksGetTriggerAsyncId such it corresponds to
async_hooks.triggerAsyncId and not async_hooks.initTriggerId.
* Use an async_context struct instead of two async_uid values.
  This change was necessary since the fixing
  AsyncHooksGetTriggerAsyncId otherwise makes it impossible to
  get the correct default trigger id. It also prevents an invalid
  triggerAsyncId in MakeCallback.
* Rename async_uid to async_id for consistency
* Rename get_uid to get_async_id
* Add get_trigger_async_id to AsyncResource class

PR-URL: #14040
Backport-PR-URL: #14109
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@addaleax
Copy link
Member Author

Landed in c7fb1ff

@addaleax addaleax closed this Jul 12, 2017
@addaleax addaleax deleted the v8.x-async-wrap-cpp-overhaul branch July 12, 2017 13:41
addaleax pushed a commit that referenced this pull request Jul 18, 2017
* Fix AsyncHooksGetTriggerAsyncId such it corresponds to
async_hooks.triggerAsyncId and not async_hooks.initTriggerId.
* Use an async_context struct instead of two async_uid values.
  This change was necessary since the fixing
  AsyncHooksGetTriggerAsyncId otherwise makes it impossible to
  get the correct default trigger id. It also prevents an invalid
  triggerAsyncId in MakeCallback.
* Rename async_uid to async_id for consistency
* Rename get_uid to get_async_id
* Add get_trigger_async_id to AsyncResource class

PR-URL: #14040
Backport-PR-URL: #14109
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Fishrock123 pushed a commit that referenced this pull request Jul 19, 2017
* Fix AsyncHooksGetTriggerAsyncId such it corresponds to
async_hooks.triggerAsyncId and not async_hooks.initTriggerId.
* Use an async_context struct instead of two async_uid values.
  This change was necessary since the fixing
  AsyncHooksGetTriggerAsyncId otherwise makes it impossible to
  get the correct default trigger id. It also prevents an invalid
  triggerAsyncId in MakeCallback.
* Rename async_uid to async_id for consistency
* Rename get_uid to get_async_id
* Add get_trigger_async_id to AsyncResource class

PR-URL: #14040
Backport-PR-URL: #14109
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addons Issues and PRs related to native addons. async_hooks Issues and PRs related to the async hooks subsystem. c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants