Skip to content

lib: remove bootstrap global context indirection - #5881

Merged
Fishrock123 merged 1 commit into
nodejs:masterfrom
Fishrock123:less-context-indirection
Mar 31, 2016
Merged

lib: remove bootstrap global context indirection#5881
Fishrock123 merged 1 commit into
nodejs:masterfrom
Fishrock123:less-context-indirection

Conversation

@Fishrock123

Copy link
Copy Markdown
Contributor

Pull Request check-list

  • Does make -j8 test (UNIX) or vcbuild test nosign (Windows) pass with
    this change (including linting)?
  • Is the commit message formatted according to CONTRIBUTING.md?

Affected core subsystem(s)

lib,bootstrap

Description of change

From an irc discussion with @bmeck, this is less confusing than relying on what the "this" context is.

@Fishrock123Fishrock123 added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. labels Mar 23, 2016
@bnoordhuis

Copy link
Copy Markdown
Member

LGTM, I suppose.

@cjihrig

Copy link
Copy Markdown
Contributor

LGTM

@bmeck

Copy link
Copy Markdown
Member

agree, the "use strict" and then old convention of using this as global was a big double take for me.

@jasnell

Copy link
Copy Markdown
Member

LGTM

@Fishrock123

Copy link
Copy Markdown
ContributorAuthor

@jasnell This poses no risk to lts, but at the same time no benefit either.

CI before landing: https://ci.nodejs.org/job/node-test-pull-request/2055/

@Fishrock123

Copy link
Copy Markdown
ContributorAuthor

Part of me wonders if this should be passed at all though? I guess this makes global in this file use the passed reference and not actually the global one?

I could probably just do it in C++ if that is even less confusing.

@bmeck

Copy link
Copy Markdown
Member

@Fishrock123 it was always using one passed via C++, it is just a convention/style gotcha

@Fishrock123

Copy link
Copy Markdown
ContributorAuthor

@bmeck I mean the only place we actually need it passed is to set <global>.global = <global> so we can access it in any scope via global, right?

@bmeck

Copy link
Copy Markdown
Member

@Fishrock123 ah, I see yes, you could manually set global via C++ on the Context's Global() and remove this.

@Fishrock123
Fishrock123force-pushed the less-context-indirection branch from d074e34 to 1dc1278CompareMarch 24, 2016 15:37
@Fishrock123

Copy link
Copy Markdown
ContributorAuthor

@jasnell

Copy link
Copy Markdown
Member

I marked it don't land on v4.x because the underlying refactoring of src/node.js hasn't been pulled back. I'm not sure if we should. @nodejs/lts

@Fishrock123

Copy link
Copy Markdown
ContributorAuthor

@jasnell This should take no effort to backport?

@jasnell

Copy link
Copy Markdown
Member

It's more a question over whether we should, not about how much effort is involved. @nodejs/lts ... what do you think?

@Fishrock123
Fishrock123force-pushed the less-context-indirection branch from 1dc1278 to e69686cCompareMarch 24, 2016 19:04
Comment threadlib/internal/bootstrap_node.js Outdated

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From #5888 (comment)

Looks this is was duplicated and unnecessary.

@Fishrock123

Copy link
Copy Markdown
ContributorAuthor

Could I get this re-LTGM'd, since I changed most of it from the original?

@cjihrig

Copy link
Copy Markdown
Contributor

LGTM

PR-URL: nodejs#5881
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@Fishrock123
Fishrock123force-pushed the less-context-indirection branch from e69686c to 21d66d6CompareMarch 30, 2016 23:59
@Fishrock123
Fishrock123 merged commit 21d66d6 into nodejs:masterMar 31, 2016
Comment threadsrc/node.cc

Local<Value> arg = env->process_object();
f->Call(global, 1, &arg);
f->Call(Null(env->isolate()), ARRAY_SIZE(&arg), &arg);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this code was changed after I reviewed it? Because ARRAY_SIZE(&arg) doesn't do what you think it does.

@evanlucas

Copy link
Copy Markdown
Contributor

With Ben's comment, perhaps we should hold off on this on v5?

@Fishrock123

Copy link
Copy Markdown
ContributorAuthor

@bnoordhuis I'm not sure what you mean by that? Trevor suggested it. It was originally 2. Does this break something?

@bnoordhuis

Copy link
Copy Markdown
Member

The problem is that ARRAY_SIZE(&arg) evaluates to sizeof(&arg) / sizeof(*&arg). It works by accident because sizeof(Local<Value>*) == sizeof(Local<Value>) but it breaks with arrays:

Local<Value> argv[] = { a, b, c }; // ARRAY_SIZE(&argv) is *not* 3 like you would expect

@MylesBorins

Copy link
Copy Markdown
Contributor

@Fishrock123 this is not landing cleanly on v5.x

@Fishrock123

Copy link
Copy Markdown
ContributorAuthor

Really? I'll take a look when get home.

@thealphanerd this is not important for the release.

Fishrock123 added a commit to Fishrock123/node that referenced this pull request Apr 7, 2016
PR-URL: nodejs#5881
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Conflicts:
lib/internal/bootstrap_node.js
src/node.cc
MylesBorins pushed a commit that referenced this pull request Apr 15, 2016
PR-URL: #5881
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Conflicts:
lib/internal/bootstrap_node.js
src/node.cc
This was referenced Apr 20, 2016
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++Issues and PRs that require attention from people who are familiar with C++.lib / srcIssues and PRs related to general changes in the lib or src directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@Fishrock123@bnoordhuis@cjihrig@bmeck@jasnell@evanlucas@MylesBorins