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

Cache the Symbol.hasInstance value #209

Closed
jasongin opened this issue Mar 29, 2017 · 3 comments
Closed

Cache the Symbol.hasInstance value #209

jasongin opened this issue Mar 29, 2017 · 3 comments
Assignees

Comments

@jasongin
Copy link
Member

jasongin commented Mar 29, 2017

For the V8 implementation of napi_instanceof, we look up the value of Symbol.hasInstance, so that we can check if a particular constructor has customized the instanceof behavior.

As an optimization, the Symbol.hasInstance value could be cached (for each napi_env), which will save some extra work of looking it up for each call to napi_instanceof.

@jasongin
Copy link
Member Author

This was suggested in the node/master PR comment: nodejs/node#11975 (comment)

@gabrielschulhof
Copy link
Collaborator

I can take this once #208 lands.

@gabrielschulhof gabrielschulhof self-assigned this Mar 29, 2017
gabrielschulhof pushed a commit to gabrielschulhof/abi-stable-node that referenced this issue Mar 29, 2017
gabrielschulhof pushed a commit to gabrielschulhof/abi-stable-node that referenced this issue Mar 30, 2017
gabrielschulhof pushed a commit to gabrielschulhof/abi-stable-node that referenced this issue Mar 30, 2017
gabrielschulhof pushed a commit to gabrielschulhof/abi-stable-node that referenced this issue Mar 30, 2017
gabrielschulhof pushed a commit to gabrielschulhof/abi-stable-node that referenced this issue Mar 31, 2017
gabrielschulhof pushed a commit to gabrielschulhof/abi-stable-node that referenced this issue Apr 3, 2017
gabrielschulhof pushed a commit to gabrielschulhof/abi-stable-node that referenced this issue Apr 3, 2017
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this issue Apr 5, 2017
This improves the performance of napi_instanceof() by retrieving
Symbol.hasInstance from the global object once and then storing a
persistent reference to it in the env.

Re nodejs/abi-stable-node#209
Re nodejs/abi-stable-node#214
@mhdawson
Copy link
Member

Closing as this has landed in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants