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

n-api: reimplement instanceof using V8 API #16143

Closed
wants to merge 1 commit into from

Conversation

hashseed
Copy link
Member

This uses the v8::Value::InstanceOf API exposed in V8 6.0 and should be performance neutral, if not improve it. By using V8's API, there is no longer the need to cache Symbol.hasInstance.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

N-API

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. dont-land-on-v4.x node-api Issues and PRs related to the Node-API. labels Oct 11, 2017
@hashseed
Copy link
Member Author

@addaleax @TimothyGu do you mind taking a look?

@addaleax
Copy link
Member

@nodejs/n-api This is a patch that won’t be applicable to previous versions of Node.js. I think that’s okay, at some point that would happen anyway, it just means that updating other copies can’t be done through verbatim copies anymore.

@hashseed
Copy link
Member Author

To be fair src/node_api.cc has existed only since March 2017. Neither Node 6 nor Node 7 has it.

@gabrielschulhof
Copy link
Contributor

gabrielschulhof commented Oct 11, 2017 via email

@gabrielschulhof
Copy link
Contributor

gabrielschulhof commented Oct 11, 2017 via email

@addaleax
Copy link
Member

@gabrielschulhof Sorry, I don’t quite follow … how would using node_internals.h make a difference here?

@gabrielschulhof
Copy link
Contributor

gabrielschulhof commented Oct 11, 2017 via email

@addaleax
Copy link
Member

Ah, I see – yeah, I wouldn’t bother. Just applying patches individually to the node-addon-api copy should be fine.

@hashseed
Copy link
Member Author

hashseed commented Oct 11, 2017

I feel like I'm missing some requirements. Why does it matter whether this patch applies to older versions? What copies are there outside of node core? What role does node_internals.h play?

My impression is that node_api.cc is supposed to be the glue between a stable API and V8. As such, it would change as V8 does. I feel like I'm mistaken?

@gabrielschulhof
Copy link
Contributor

gabrielschulhof commented Oct 11, 2017 via email

@hashseed
Copy link
Member Author

I see. Thanks for the explanation. Wouldn't you be better served to simply keep a new copy of src/node_api.cc for every V8 version in node-addon-api and ifdef between them?

@hashseed
Copy link
Member Author

Somebody merge this?

@addaleax
Copy link
Member

@hashseed
Copy link
Member Author

Is CI stuck somehow? Looks like every one of these checks finished with SUCCESS, except for windows-fanned, which finished with UNSTABLE.

@TimothyGu
Copy link
Member

TimothyGu commented Oct 16, 2017

@hashseed The GitHub integration for CI stopped working a while ago.

fhinkel pushed a commit to fhinkel/node that referenced this pull request Oct 16, 2017
This uses the v8::Value::InstanceOf API exposed in V8 6.0 and should
be performance neutral, if not improve it. By using V8's API, there
is no longer the need to cache Symbol.hasInstance.

PR-URL: nodejs#16143
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Timothy Gu <[email protected]>
@fhinkel
Copy link
Member

fhinkel commented Oct 16, 2017

Thanks! Landed in c81fd7c

@fhinkel fhinkel closed this Oct 16, 2017
@hashseed
Copy link
Member Author

Awesome. Thanks!

@hashseed hashseed deleted the instanceof branch October 16, 2017 07:35
targos pushed a commit that referenced this pull request Oct 18, 2017
This uses the v8::Value::InstanceOf API exposed in V8 6.0 and should
be performance neutral, if not improve it. By using V8's API, there
is no longer the need to cache Symbol.hasInstance.

PR-URL: #16143
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Timothy Gu <[email protected]>
addaleax pushed a commit to ayojs/ayo that referenced this pull request Oct 18, 2017
This uses the v8::Value::InstanceOf API exposed in V8 6.0 and should
be performance neutral, if not improve it. By using V8's API, there
is no longer the need to cache Symbol.hasInstance.

PR-URL: nodejs/node#16143
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Timothy Gu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. node-api Issues and PRs related to the Node-API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants