GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: start annotating native code side effect by TimothyGu · Pull Request #21458 · nodejs/node

Conversation

@TimothyGu

@TimothyGu TimothyGu commented Jun 22, 2018

Copy link
Copy Markdown
Member

Allows eager evaluation to take place for many builtin modules.

screenshot from 2018-06-22 01-37-13

Refs: #20977

/cc @nodejs/v8-inspector @benjamingr

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

benjamingr reacted with thumbs up emoji devsnek, addaleax, targos, and BridgeAR reacted with heart emoji
All reactions
  • 👍 1 reaction
  • ❤️ 4 reactions
@TimothyGu
src: start annotating native code side effect
7132853
Refs: nodejs#20977
@TimothyGu TimothyGu added c++ Issues and PRs that require attention from people who are familiar with C++. v8 engine Issues and PRs related to the V8 dependency. inspector Issues and PRs related to the V8 inspector protocol. labels Jun 22, 2018
@nodejs-github-bot

nodejs-github-bot commented Jun 22, 2018

Copy link
Copy Markdown
Collaborator

@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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. labels Jun 22, 2018
addaleax
addaleax approved these changes Jun 22, 2018
View reviewed changes
devsnek
devsnek approved these changes Jun 22, 2018
View reviewed changes
@TimothyGu

TimothyGu commented Jun 22, 2018

Copy link
Copy Markdown
Member Author

Full CI: https://ci.nodejs.org/job/node-test-pull-request/15563/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

benjamingr
benjamingr approved these changes Jun 22, 2018
View reviewed changes
bnoordhuis
bnoordhuis approved these changes Jun 22, 2018
View reviewed changes
Comment thread src/env-inl.h
NewFunctionTemplate(callback,
v8::Local<v8::Signature>(),
// TODO(TimothyGu): Investigate if SetMethod is ever
// used for constructors.

@bnoordhuis bnoordhuis Jun 22, 2018

Copy link
Copy Markdown
Member

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@TimothyGu TimothyGu Jun 22, 2018

Copy link
Copy Markdown
Member Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread src/node_crypto.cc Outdated
env->SetMethod(target, "getHashes", GetHashes);
env->SetMethod(target, "getCurves", GetCurves);
env->SetMethod(target, "randomBytes", RandomBytes,
SideEffectType::kHasNoSideEffect);

@bnoordhuis bnoordhuis Jun 22, 2018

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@TimothyGu TimothyGu Jun 22, 2018

Copy link
Copy Markdown
Member Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
cjihrig
cjihrig approved these changes Jun 22, 2018
View reviewed changes
@TimothyGu
fixup! src: start annotating native code side effect
c5f4cb5
crypto
joyeecheung
joyeecheung approved these changes Jun 22, 2018
View reviewed changes
bnoordhuis
bnoordhuis reviewed Jun 22, 2018
View reviewed changes
Comment thread src/node_crypto.cc
Signature::New(env->isolate(), t));
Signature::New(env->isolate(), t),
// TODO(TimothyGu): should be deny
ConstructorBehavior::kAllow,

@bnoordhuis bnoordhuis Jun 22, 2018

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@TimothyGu TimothyGu Jun 22, 2018

Copy link
Copy Markdown
Member Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jasnell
jasnell reviewed Jun 22, 2018
View reviewed changes
Comment thread src/node.cc Outdated
env->SetMethod(process, "getgid", GetGid);
env->SetMethod(process, "getegid", GetEGid);
env->SetMethod(process, "getgroups", GetGroups);
env->SetMethod(process, "getuid", GetUid,

@jasnell jasnell Jun 22, 2018

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

TimothyGu reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
TimothyGu added 2 commits June 22, 2018 21:43
@TimothyGu
fixup! fixup! src: start annotating native code side effect
d418bb8
@TimothyGu
fixup! src: start annotating native code side effect
a129a6f
@TimothyGu

TimothyGu commented Jun 23, 2018

Copy link
Copy Markdown
Member Author

CI: https://ci.nodejs.org/job/node-test-pull-request/15571/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell approved these changes Jun 23, 2018
View reviewed changes
@bnoordhuis

bnoordhuis commented Jun 23, 2018

Copy link
Copy Markdown
Member

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.

addaleax reacted with thumbs up emoji TimothyGu and benjamingr reacted with laugh emoji
All reactions
  • 👍 1 reaction
  • 😄 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Jun 23, 2018

Copy link
Copy Markdown
Member

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Jun 23, 2018

Copy link
Copy Markdown
Member

It's a fairly well known idea that "safe" methods have no side effects

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Jun 23, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Jun 23, 2018

Copy link
Copy Markdown
Member

and NSE conveys no useful information

@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.

joyeecheung reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TimothyGu

TimothyGu commented Jun 24, 2018

Copy link
Copy Markdown
Member Author

@addaleax Sure, I'll fix that later.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@benjamingr

benjamingr commented Jun 24, 2018

Copy link
Copy Markdown
Member

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/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Jun 24, 2018

Copy link
Copy Markdown
Member

"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)).

benjamingr, addaleax, and TimothyGu reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TimothyGu
fixup! fixup! src: start annotating native code side effect
c43658d
benjamingr
benjamingr approved these changes Jun 24, 2018
View reviewed changes

@benjamingr benjamingr left a comment

Copy link
Copy Markdown
Member

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
bnoordhuis
bnoordhuis approved these changes Jun 24, 2018
View reviewed changes
jasnell
jasnell approved these changes Jun 24, 2018
View reviewed changes
@TimothyGu

TimothyGu commented Jun 26, 2018

Copy link
Copy Markdown
Member Author

CI: https://ci.nodejs.org/job/node-test-pull-request/15623/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TimothyGu

TimothyGu commented Jun 26, 2018

Copy link
Copy Markdown
Member Author

Landed in 65f6173.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TimothyGu TimothyGu closed this Jun 26, 2018
@TimothyGu
TimothyGu deleted the side-effects branch June 26, 2018 03:16
TimothyGu added a commit that referenced this pull request Jun 26, 2018
@TimothyGu
src: start annotating native code side effect
65f6173
PR-URL: #21458
Refs: #20977
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@targos targos added the backport-requested-v10.x label Jun 26, 2018
@targos

targos commented Jun 26, 2018

Copy link
Copy Markdown
Member

Depends on #21105 to land on v10.x

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@targos targos mentioned this pull request Jul 14, 2018
src: add HandleWrap::AddWrapMethods #21769
Closed
2 tasks done
@targos targos removed the backport-requested-v10.x label Jul 14, 2018
targos pushed a commit that referenced this pull request Jul 14, 2018
@TimothyGu @targos
src: start annotating native code side effect
51d613d
PR-URL: #21458
Refs: #20977
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@targos targos mentioned this pull request Jul 17, 2018
v10.7.0 proposal #21851
Merged
This was referenced Jul 18, 2018
2018-07-18 Version 10.7.0 (Current) @targos beevelop/docker-nodejs#207
Closed
2018-07-18 Version 10.7.0 (Current) @targos beevelop/docker-nodejs#208
Closed
2018-07-18 Version 10.7.0 (Current) @targos beevelop/docker-nodejs#209
Closed
2018-07-18 Version 10.7.0 (Current) @targos beevelop/docker-nodejs#210
Closed
2018-07-18 Version 10.7.0 (Current) @targos beevelop/docker-nodejs#211
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bnoordhuis bnoordhuis bnoordhuis approved these changes
@jasnell jasnell jasnell approved these changes
@addaleax addaleax addaleax approved these changes
@benjamingr benjamingr benjamingr approved these changes
@cjihrig cjihrig cjihrig approved these changes
@joyeecheung joyeecheung joyeecheung approved these changes
+1 more reviewer
@devsnek devsnek devsnek approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. inspector Issues and PRs related to the V8 inspector protocol. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. v8 engine Issues and PRs related to the V8 dependency.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

10 participants

@TimothyGu @nodejs-github-bot @bnoordhuis @jasnell @addaleax @benjamingr @targos @cjihrig @joyeecheung @devsnek
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.