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

src: use CreateEnvironment instead of inlining its code where possible #45886

Merged
merged 3 commits into from Dec 21, 2022

Conversation

addaleax
Copy link
Member

We had a number of places in which we created an Environment instance by performing each step in CreateEnvironment manually. Instead, just call the function itself.

We had a number of places in which we created an `Environment` instance
by performing each step in `CreateEnvironment` manually. Instead,
just call the function itself.
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/startup

@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 related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Dec 16, 2022
@addaleax addaleax added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 16, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 16, 2022
@nodejs-github-bot
Copy link
Collaborator

src/api/environment.cc Outdated Show resolved Hide resolved
inspector_parent_handle.get())->impl));
env->InitializeInspector(std::move(
static_cast<InspectorParentHandleImpl*>(inspector_parent_handle.get())
->impl));
Copy link
Member Author

Choose a reason for hiding this comment

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

This is now just a clang-format leftover after addressing review comments, I’d leave it if it’s all the same to everyone.

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@addaleax addaleax added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 20, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 20, 2022
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@addaleax addaleax added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Dec 21, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 21, 2022
@nodejs-github-bot nodejs-github-bot merged commit 01323d5 into nodejs:main Dec 21, 2022
@nodejs-github-bot
Copy link
Collaborator

Landed in 01323d5

@addaleax addaleax deleted the inline-createnevironment branch December 21, 2022 16:26
targos pushed a commit that referenced this pull request Jan 1, 2023
We had a number of places in which we created an `Environment` instance
by performing each step in `CreateEnvironment` manually. Instead,
just call the function itself.

PR-URL: #45886
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
@RafaelGSS RafaelGSS mentioned this pull request Jan 2, 2023
RafaelGSS pushed a commit that referenced this pull request Jan 4, 2023
We had a number of places in which we created an `Environment` instance
by performing each step in `CreateEnvironment` manually. Instead,
just call the function itself.

PR-URL: #45886
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Jan 5, 2023
We had a number of places in which we created an `Environment` instance
by performing each step in `CreateEnvironment` manually. Instead,
just call the function itself.

PR-URL: #45886
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
@juanarbol juanarbol added the backport-requested-v18.x PRs awaiting manual backport to the v18.x-staging branch. label Jan 22, 2023
@juanarbol
Copy link
Member

This is not landing cleanly in v18.x, it is generating the. next compile errors:

../src/node_snapshotable.cc:1174:16: error: use of undeclared identifier 'ExitCode'
        return ExitCode::kBootstrapFailure;
               ^
../src/node_snapshotable.cc:1277:73: error: function definition is not allowed here
                              const std::vector<std::string> exec_args) {
                                                                        ^
../src/node_snapshotable.cc:1287:21: error: qualified reference to 'SnapshotableObject' is a constructor name rather than a type in this context
SnapshotableObject::SnapshotableObject(Environment* env,
                    ^
../src/node_snapshotable.cc:1287:40: error: 'Environment' does not refer to a value
SnapshotableObject::SnapshotableObject(Environment* env,
                                       ^
../src/node_v8.h:13:7: note: declared here
class Environment;
      ^
../src/node_snapshotable.cc:1288:54: error: expected '(' for function-style cast or type construction
                                       Local<Object> wrap,
                                       ~~~~~~~~~~~~~ ^
../src/node_snapshotable.cc:1289:40: error: 'EmbedderObjectType' does not refer to a value
                                       EmbedderObjectType type)
                                       ^
../src/node_snapshotable.h:32:12: note: declared here
enum class EmbedderObjectType : uint8_t {
           ^
../src/node_snapshotable.cc:1518:54: error: no member named 'mksnapshot' in namespace 'node'
NODE_MODULE_CONTEXT_AWARE_INTERNAL(mksnapshot, node::mksnapshot::Initialize)
                                               ~~~~~~^
../src/node_binding.h:48:42: note: expanded from macro 'NODE_MODULE_CONTEXT_AWARE_INTERNAL'
  NODE_MODULE_CONTEXT_AWARE_CPP(modname, regfunc, nullptr, NM_F_INTERNAL)
                                         ^~~~~~~
../src/node_binding.h:34:43: note: expanded from macro 'NODE_MODULE_CONTEXT_AWARE_CPP'
      (node::addon_context_register_func)(regfunc),                            \
                                          ^~~~~~~
../src/node_snapshotable.cc:1520:38: error: no member named 'mksnapshot' in namespace 'node'
                               node::mksnapshot::RegisterExternalReferences)
                               ~~~~~~^
../src/node_external_reference.h:148:5: note: expanded from macro 'NODE_MODULE_EXTERNAL_REFERENCE'
    func(registry);                                                            \
    ^~~~
../src/node_snapshotable.cc:1520:77: error: expected '}'
                               node::mksnapshot::RegisterExternalReferences)
                                                                            ^
../src/node_snapshotable.cc:27:16: note: to match this '{'
namespace node {
               ^
9 errors generated.

@addaleax
Copy link
Member Author

@juanarbol opened #46330 👍

@addaleax addaleax added backport-open-v18.x Indicate that the PR has an open backport. and removed backport-requested-v18.x PRs awaiting manual backport to the v18.x-staging branch. labels Jan 24, 2023
addaleax added a commit to addaleax/node that referenced this pull request Jan 24, 2023
We had a number of places in which we created an `Environment` instance
by performing each step in `CreateEnvironment` manually. Instead,
just call the function itself.

PR-URL: nodejs#45886
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
addaleax added a commit to addaleax/node that referenced this pull request Feb 9, 2023
We had a number of places in which we created an `Environment` instance
by performing each step in `CreateEnvironment` manually. Instead,
just call the function itself.

PR-URL: nodejs#45886
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
juanarbol pushed a commit to addaleax/node that referenced this pull request Feb 24, 2023
We had a number of places in which we created an `Environment` instance
by performing each step in `CreateEnvironment` manually. Instead,
just call the function itself.

PR-URL: nodejs#45886
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
juanarbol pushed a commit that referenced this pull request Mar 1, 2023
We had a number of places in which we created an `Environment` instance
by performing each step in `CreateEnvironment` manually. Instead,
just call the function itself.

PR-URL: #45886
Backport-PR-URL: #46330
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
@juanarbol juanarbol mentioned this pull request Mar 3, 2023
juanarbol pushed a commit that referenced this pull request Mar 5, 2023
We had a number of places in which we created an `Environment` instance
by performing each step in `CreateEnvironment` manually. Instead,
just call the function itself.

PR-URL: #45886
Backport-PR-URL: #46330
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-open-v18.x Indicate that the PR has an open backport. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants