GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: use JS inheritance for `AsyncWrap` by addaleax · Pull Request #23094 · nodejs/node

Conversation

@addaleax

@addaleax addaleax commented Sep 25, 2018

Copy link
Copy Markdown
Member

For all classes descending from AsyncWrap, use JS inheritance
instead of manually adding methods to the individual classes.

This allows cleanup of some code around transferring handles
over IPC.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@addaleax
src: use JS inheritance for AsyncWrap
b2eeb79
For all classes descending from `AsyncWrap`, use JS inheritance
instead of manually adding methods to the individual classes.

This allows cleanup of some code around transferring handles
over IPC.
@nodejs-github-bot

nodejs-github-bot commented Sep 25, 2018

Copy link
Copy Markdown
Collaborator

@addaleax build started: https://ci.nodejs.org/blue/organizations/jenkins/node-test-pull-request-lite-pipeline/detail/node-test-pull-request-lite-pipeline/1021/pipeline

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@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 involving general changes in the lib/ or src/ directories. labels Sep 25, 2018
@addaleax

addaleax commented Sep 25, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

CI: https://ci.nodejs.org/job/node-test-pull-request/17442/
CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1559/
CITGM (master): https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1560/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

joyeecheung
joyeecheung approved these changes Sep 26, 2018
View reviewed changes

@joyeecheung joyeecheung left a comment

Copy link
Copy Markdown
Member

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.

YES!!!

Left a few comments, but nothing blocking.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/async_wrap.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/env.h Outdated
V(async_hooks_init_function, v8::Function) \
V(async_hooks_promise_resolve_function, v8::Function) \
V(async_wrap_constructor_template, v8::FunctionTemplate) \
V(async_wrap_object_constructor_template, v8::FunctionTemplate) \

@joyeecheung joyeecheung Sep 26, 2018

Copy link
Copy Markdown
Member

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.

Maybe use ctor for this name as well, for consistency?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@addaleax addaleax Sep 27, 2018

Copy link
Copy Markdown
Member Author

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.

Done!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/process_wrap.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/stream_wrap.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

addaleax added 2 commits September 27, 2018 08:26
@addaleax
fixup! src: use JS inheritance for AsyncWrap
0b866b6
@addaleax
fixup! src: use JS inheritance for AsyncWrap
70b828b
@jasnell

jasnell commented Sep 28, 2018

Copy link
Copy Markdown
Member

Definitely a good idea, I think, but is this going to be semver-major?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Sep 29, 2018

Copy link
Copy Markdown
Member Author

@jasnell If necessary, I would be okay with that, but could you explain why this is semver-major? It doesn’t touch public API or remove methods, it just moves them to a different position on the prototype chain (of internal objects).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Sep 29, 2018

Copy link
Copy Markdown
Member

Largely defensive. It shouldn't be breaking but as we've seen many times, it pays to be careful. At the very least we need a citgm run to be sure

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Sep 29, 2018

Copy link
Copy Markdown
Member Author

I ran CITGM – there are a lot of failures because of #23122, but in the diff between the run here and the master run, I didn’t find anything that would point to issues with this PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Sep 29, 2018

Copy link
Copy Markdown
Member

Hopefully ok then :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Sep 29, 2018

Copy link
Copy Markdown
Member Author

@jasnell I think this will require a backport PR for v10.x anyway … let’s run CITGM on that as well, that should give a much clearer picture.

jasnell reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

joyeecheung
joyeecheung approved these changes Sep 29, 2018
View reviewed changes

@joyeecheung joyeecheung left a comment

Copy link
Copy Markdown
Member

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.

Still LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@addaleax

addaleax commented Sep 30, 2018

Copy link
Copy Markdown
Member Author

New CI: https://ci.nodejs.org/job/node-test-pull-request/17517/

(This still needs to wait for a second approval, or two more days.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax addaleax added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Sep 30, 2018
danbev
danbev approved these changes Oct 2, 2018
View reviewed changes
@danbev

danbev commented Oct 2, 2018

Copy link
Copy Markdown
Contributor

Re-run of node-test-commit-aix.
Re-run of node-test-commit-windows-fanned.
Re-run of node-test-commit-linux,

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung joyeecheung mentioned this pull request Oct 2, 2018
CI failures: 20180927-20181002 nodejs/reliability#18
Closed
jasnell
jasnell approved these changes Oct 2, 2018
View reviewed changes
@addaleax

addaleax commented Oct 3, 2018

Copy link
Copy Markdown
Member Author

Windows again: https://ci.nodejs.org/job/node-test-commit-windows-fanned/21222/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Oct 3, 2018

Copy link
Copy Markdown
Member Author

Btw, @joyeecheung … just thinking out loud: The most natural way to do mirror the C++ multiple inheritance might be to create a second native JS class (e.g. StreamBase) and have getters so that from any given object, both are accessible? For example, if handle is a native TCP handle, handle.stream instanceof StreamBase && handle.stream.wrap === handle (the name wrap is probably to be replaced with something better)?

That sounds semver-major to me, though, and I still have some native stream refactoring that I’d like to do, so maybe I’d keep that approach in mind and we could implement it late in the Node 11 release cycle?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung

joyeecheung commented Oct 3, 2018

Copy link
Copy Markdown
Member

create a second native JS class (e.g. StreamBase) and have getters so that from any given object, both are accessible?

Isn't that kind of like StreamBase::AddMethods done in JS land with declarative accessors? But come to think of it, if we are going to do multiple inheritance in C++, then it's probably better to keep doing inheritance in JS instead of going with inheritance in C++ while with composition in JS - that seems more confusing than doing multiple inheritance on both sides.

(Or..maybe we should do it the other way around, why does LibuvStreamWrap have multiple inheritance in the first place?)
(either way I believe it's going to be semver-major so yeah, +1 to do it later)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Oct 3, 2018

Copy link
Copy Markdown
Member Author

Or..maybe we should do it the other way around, why does LibuvStreamWrap have multiple inheritance in the first place?

Because it’s both a class that wraps a libuv handle, and is a stream at the same time – it does make sense to use multiple inheritance here…

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Oct 3, 2018

Copy link
Copy Markdown
Member Author

… and again, Windows: https://ci.nodejs.org/job/node-test-commit-windows-fanned/21229/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Oct 3, 2018

Copy link
Copy Markdown
Member Author

Landed in d527dde

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax addaleax closed this Oct 3, 2018
@addaleax
addaleax deleted the __proto__ branch October 3, 2018 20:57
addaleax added a commit that referenced this pull request Oct 3, 2018
@addaleax
src: use JS inheritance for AsyncWrap
d527dde
For all classes descending from `AsyncWrap`, use JS inheritance
instead of manually adding methods to the individual classes.

This allows cleanup of some code around transferring handles
over IPC.

PR-URL: #23094
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: James M Snell <[email protected]>
addaleax added a commit to addaleax/node that referenced this pull request Oct 3, 2018
@addaleax
src: use JS inheritance for AsyncWrap
12c9de3
For all classes descending from `AsyncWrap`, use JS inheritance
instead of manually adding methods to the individual classes.

This allows cleanup of some code around transferring handles
over IPC.

PR-URL: nodejs#23094
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@addaleax addaleax added the backported-to-v10.x label Oct 3, 2018
@addaleax addaleax mentioned this pull request Oct 3, 2018
(v10.x backport) src: use JS inheritance for AsyncWrap #23247
Closed
targos pushed a commit that referenced this pull request Oct 7, 2018
@addaleax @targos
src: use JS inheritance for AsyncWrap
5bf2309
For all classes descending from `AsyncWrap`, use JS inheritance
instead of manually adding methods to the individual classes.

This allows cleanup of some code around transferring handles
over IPC.

Backport-PR-URL: #23247
PR-URL: #23094
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: James M Snell <[email protected]>
targos pushed a commit that referenced this pull request Oct 7, 2018
@addaleax @targos
src: use JS inheritance for AsyncWrap
5a83967
For all classes descending from `AsyncWrap`, use JS inheritance
instead of manually adding methods to the individual classes.

This allows cleanup of some code around transferring handles
over IPC.

Backport-PR-URL: #23247
PR-URL: #23094
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@targos targos mentioned this pull request Oct 7, 2018
Release proposal: v10.12.0 #23313
Merged
This was referenced Oct 10, 2018
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#225
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#239
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#226
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#240
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#227
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#241
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#242
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#228
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#243
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#229
Closed
jasnell pushed a commit that referenced this pull request Oct 17, 2018
@addaleax @jasnell
src: use JS inheritance for AsyncWrap
982a9ac
For all classes descending from `AsyncWrap`, use JS inheritance
instead of manually adding methods to the individual classes.

This allows cleanup of some code around transferring handles
over IPC.

PR-URL: #23094
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jasnell jasnell jasnell approved these changes
@joyeecheung joyeecheung joyeecheung approved these changes
+1 more reviewer
@danbev danbev danbev approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@addaleax @nodejs-github-bot @jasnell @danbev @joyeecheung
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.