Skip to content
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

lib: remove bootstrap global context indirection #5881

Merged
merged 1 commit into from
Mar 31, 2016

Conversation

Fishrock123
Copy link
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.

@Fishrock123 Fishrock123 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
Member

LGTM, I suppose.

@cjihrig
Copy link
Contributor

cjihrig commented Mar 24, 2016

LGTM

@bmeck
Copy link
Member

bmeck commented Mar 24, 2016

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

@jasnell
Copy link
Member

jasnell commented Mar 24, 2016

LGTM

@Fishrock123
Copy link
Contributor Author

@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
Contributor Author

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
Member

bmeck commented Mar 24, 2016

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

@Fishrock123
Copy link
Contributor Author

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

bmeck commented Mar 24, 2016

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

@Fishrock123 Fishrock123 force-pushed the less-context-indirection branch from d074e34 to 1dc1278 Compare March 24, 2016 15:37
@Fishrock123
Copy link
Contributor Author

@jasnell
Copy link
Member

jasnell commented Mar 24, 2016

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
Contributor Author

@jasnell This should take no effort to backport?

@jasnell
Copy link
Member

jasnell commented Mar 24, 2016

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

@Fishrock123 Fishrock123 force-pushed the less-context-indirection branch from 1dc1278 to e69686c Compare March 24, 2016 19:04
@@ -208,7 +207,6 @@

function setupGlobalVariables() {
global.process = process;
global.global = global;
Copy link
Contributor Author

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
Contributor Author

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

@cjihrig
Copy link
Contributor

cjihrig commented Mar 30, 2016

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 Fishrock123 force-pushed the less-context-indirection branch from e69686c to 21d66d6 Compare March 30, 2016 23:59
@Fishrock123 Fishrock123 merged commit 21d66d6 into nodejs:master Mar 31, 2016
Local<Value> arg = env->process_object();
f->Call(global, 1, &arg);
f->Call(Null(env->isolate()), ARRAY_SIZE(&arg), &arg);
Copy link
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
Contributor

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

@Fishrock123
Copy link
Contributor Author

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

@bnoordhuis
Copy link
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
Contributor

@Fishrock123 this is not landing cleanly on v5.x

@Fishrock123
Copy link
Contributor Author

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 free to 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 / src Issues 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