-
Notifications
You must be signed in to change notification settings - Fork 30k
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: create extras internal binding #18420
Conversation
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.
Is this used anywhere? If not I’d rather defer this PR until a solid use case materializes.
@TimothyGu i'd like to at least use createPrivateSymbol in place of our existing weakmap usage |
@devsnek Are there existing places where WeakMap is used? If so, please change them in this PR. We don’t want currently unused and untested code lying around. |
@TimothyGu not at the moment but incoming code for vm.Module uses it, this pr can be kept open until that lands i guess., i can also replace the uncurryThis in internal/util/types |
deae560
to
9261619
Compare
9261619
to
b420212
Compare
@TimothyGu i made a slight change to the internal binding to better expose it, you might wanna take another look |
The things in V8's prologue.js are internal helpers, they're not intended for public consumption. That doesn't mean you absolutely can't use them but there would have to be compelling reasons and a fallback plan for when they change or disappear. By the way, |
@bnoordhuis it was my understanding they were intended to be used by embedders, and it actually can't be required because it's not packed into node_javascript.cc |
The ability to add bindings, yes; not that particular bindings file, as far as I know. @hashseed Are the functions in prologue.js intended to be used by embedders? |
V8 extras has been an experiment with blink to implement some blink features in JavaScript. It has never really taken off, and we are now migrating most builtins in V8 away from JavaScript. I would advise against exposing and later on relying on V8 extras bindings. It is somewhat debatable, but I wouldn't consider them official APIs. If you want to create private symbols using V8's C++ API. |
@gsathya recommended using V8 Extras APIs for If so it would be very sad, and would invalidate some creative applications of V8 Extras like implementation of a context-aware |
To be honest: V8 Extras is not well tested and a lot of it is legacy code now, especially the things added for performance reasons. I guess if we seriously want to use it outside of it's initial scope we could that, but then we should shrink it to the bare minimum and throw a lot of tests at it. |
perhaps there could be like a Symbol::Private subclass that just flipped set_is_private, or maybe |
FWIW my interpretation of V8 extras' scope has always included these kind of Node.js use cases. But, without a second consumer maintaining it has been tricky. Shrinking away some things (like, as you mentioned, simpleBind) would be good. I think it has a pretty good set of tests but more is always nice. |
b420212
to
6bc7bc9
Compare
@domenic or @bmeurer or @hashseed do private symbols get optimized into the shape of a constructor? as an example const x = createPrivateSymbol('x');
function XWrap() {
this.t = undefined; // i know this line matters
this[x] = undefined; // does this line matter
}
XWrap.prototype.fillX = function(val) {
this[x] = val;
} |
6bc7bc9
to
497b962
Compare
@devsnek Yes. See the first part of https://v8project.blogspot.com/2018/01/hash-code.html, which indirectly talks about private symbols. |
v8 team encouraged us to not use this, as they are trying to get rid of it, and to settle for weakmaps until private class fields land |
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)