| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
@TimothyGu build started: https://ci.nodejs.org/blue/organizations/jenkins/node-test-pull-request-lite-pipeline/detail/node-test-pull-request-lite-pipeline/117/pipeline |
Sorry, something went wrong.
Sorry, something went wrong.
| 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?
Sorry, something went wrong.
There was a problem hiding this comment.
I'd rather leave that to a separate PR is what I meant.
Sorry, something went wrong.
| 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.
Sorry, something went wrong.
There was a problem hiding this comment.
Hmm, I didn't realize RandomBytes was async. I'll remove this part then.
Sorry, something went wrong.
| 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.
Sorry, something went wrong.
There was a problem hiding this comment.
Oops, good catch. Fixed.
Sorry, something went wrong.
| 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.
Sorry, something went wrong.
Sorry, something went wrong.
|
SetSafeMethod() is a bad name. Safe how? f you want something short, use SetMethodNSE() - a little cryptic but on point. We could then later add SetMethodNSFW() for methods you wouldn't want to be seen calling at the office. |
Sorry, something went wrong.
|
I disagree on Safe being bad here... It's a fairly well known idea that "safe" methods have no side effects and NSE conveys no useful information. I think the code comments are enough to convey what Safe means here. |
Sorry, something went wrong.
We have functions such as SafeGetenv() and SafeX509ExtPrint() where the Safe means they go the extra mile to stay secure. It doesn't denote anything about side effects. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
@TimothyGu I’d suggest just spelling it out then as NoSideEffect, if that’s alright with you? I agree with Ben that Safe is not a great name, it doesn’t convey much information either. |
Sorry, something went wrong.
|
@addaleax Sure, I'll fix that later. |
Sorry, something went wrong.
|
For what it's worth Pure is typically used to indicate a function has no side effects - at least a lot more often than Safe or NSE. https://www.sitepoint.com/functional-programming-pure-functions/ |
Sorry, something went wrong.
|
"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 process.uptime(). Compare gcc's __attribute__((pure)). |
Sorry, something went wrong.
There was a problem hiding this comment.
Still looks good after rename
Sorry, something went wrong.
Sorry, something went wrong.
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>
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>
| Back | FazBrowse Home | New Git URL |
Allows eager evaluation to take place for many builtin modules.
Refs: #20977
/cc @nodejs/v8-inspector @benjamingr
Checklist