-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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: start annotating native code side effect #21458
Conversation
NewFunctionTemplate(callback, | ||
v8::Local<v8::Signature>(), | ||
// TODO(TimothyGu): Investigate if SetMethod is ever | ||
// used for constructors. |
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.
That's easy to check, isn't it? Or do you suspect make test
will miss instances?
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.
I'd rather leave that to a separate PR is what I meant.
src/node_crypto.cc
Outdated
env->SetMethod(target, "getHashes", GetHashes); | ||
env->SetMethod(target, "getCurves", GetCurves); | ||
env->SetMethod(target, "randomBytes", RandomBytes, | ||
SideEffectType::kHasNoSideEffect); |
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 there a reason you annotated randomBytes but not pbkdf2 and scrypt? They all use the thread pool.
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.
Hmm, I didn't realize RandomBytes
was async. I'll remove this part then.
src/node_crypto.cc
Outdated
Signature::New(env->isolate(), t)); | ||
Signature::New(env->isolate(), t), | ||
// TODO(TimothyGu): should be deny | ||
ConstructorBehavior::kAllow, |
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.
Should be /* length */ 0, ConstructorBehavior::kAllow,
. Likewise on line 3968.
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.
Oops, good catch. Fixed.
src/node.cc
Outdated
env->SetMethod(process, "getgid", GetGid); | ||
env->SetMethod(process, "getegid", GetEGid); | ||
env->SetMethod(process, "getgroups", GetGroups); | ||
env->SetMethod(process, "getuid", GetUid, |
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.
Just a thought... but a env->SetSafeMethod(process, ...)
variant that sets SideEfectType::kHasNoSideEffect
automatically may be worthwhile.
We could then later add |
I disagree on |
We have functions such as |
I'm not even remotely interested in debating it so whatever method name folks think is appropriate is fine with me. Having the utility method is what I wanted so I'm good with this. |
@TimothyGu I’d suggest just spelling it out then as |
@addaleax Sure, I'll fix that later. |
For what it's worth |
"Pure" suggests it's safe to collapse multiple calls because the return value depends only on the inputs. That clearly isn't true for functions such as Compare gcc's |
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 looks good after rename
Landed in 65f6173. |
PR-URL: #21458 Refs: #20977 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Depends on #21105 to land on v10.x |
PR-URL: #21458 Refs: #20977 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Allows eager evaluation to take place for many builtin modules.
Refs: #20977
/cc @nodejs/v8-inspector @benjamingr
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes