src: start annotating native code side effect#21458
src: start annotating native code side effect#21458TimothyGu wants to merge 5 commits intonodejs:masterfrom
Conversation
| NewFunctionTemplate(callback, | ||
| v8::Local<v8::Signature>(), | ||
| // TODO(TimothyGu): Investigate if SetMethod is ever | ||
| // used for constructors. |
There was a problem hiding this comment.
That's easy to check, isn't it? Or do you suspect make test will miss instances?
There was a problem hiding this comment.
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.
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.
Hmm, I didn't realize RandomBytes was async. I'll remove this part then.
| Signature::New(env->isolate(), t)); | ||
| Signature::New(env->isolate(), t), | ||
| // TODO(TimothyGu): should be deny | ||
| ConstructorBehavior::kAllow, |
There was a problem hiding this comment.
Should be /* length */ 0, ConstructorBehavior::kAllow,. Likewise on line 3968.
There was a problem hiding this comment.
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.
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 |
benjamingr
left a comment
There was a problem hiding this comment.
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