Skip to content

Conversation

@joyeecheung
Copy link
Member

@joyeecheung joyeecheung commented Jan 5, 2019

  • Remove NativeModule._source - the compilation is now entirely
    done in C++ and process.binding('natives') is implemented
    directly in the binding loader so there is no need to store
    additional source code strings.
  • Instead of using an object as NativeModule._cached and insert
    into it after compilation of each native module, simply prebuild
    a JS map filled with all the native modules and infer the
    state of compilation through mod.loading/mod.loaded.
  • Rename NativeModule.nonInternalExists to
    NativeModule.canBeRequiredByUsers and precompute that
    property for all the native modules during bootstrap instead
    of branching in every require call during runtime. This also fixes
    the bug where worker_threads can be made available with
    --expose-internals
  • Rename NativeModule.requireForDeps to
    NativeModule.requireWithFallbackInDeps.
  • Add a test to make sure we do not accidentally leak any module
    to the global namespace.
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
@nodejs-github-bot nodejs-github-bot added the lib / src Issues and PRs related to general changes in the lib or src directory. label Jan 5, 2019
@mscdex
Copy link
Contributor

mscdex commented Jan 5, 2019

Typo in commit message: s/redudant/redundant/

- Remove `NativeModule._source` - the compilation is now entirely done in C++ and `process.binding('natives')` is implemented directly in the binding loader so there is no need to store additional source code strings. - Instead of using an object as `NativeModule._cached` and insert into it after compilation of each native module, simply prebuild a JS map filled with all the native modules and infer the state of compilation through `mod.loading`/`mod.loaded`. - Rename `NativeModule.nonInternalExists` to `NativeModule.canBeRequiredByUsers` and precompute that property for all the native modules during bootstrap instead of branching in every require call during runtime. - Rename `NativeModule.requireForDeps` to `NativeModule.requireWithFallbackInDeps`. - Add a test to make sure we do not accidentally leak any module to the global namespace.
@joyeecheung joyeecheung added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 12, 2019
@joyeecheung
Copy link
Member Author

Landed in 92e95f1

joyeecheung added a commit that referenced this pull request Jan 12, 2019
- Remove `NativeModule._source` - the compilation is now entirely done in C++ and `process.binding('natives')` is implemented directly in the binding loader so there is no need to store additional source code strings. - Instead of using an object as `NativeModule._cached` and insert into it after compilation of each native module, simply prebuild a JS map filled with all the native modules and infer the state of compilation through `mod.loading`/`mod.loaded`. - Rename `NativeModule.nonInternalExists` to `NativeModule.canBeRequiredByUsers` and precompute that property for all the native modules during bootstrap instead of branching in every require call during runtime. This also fixes the bug where `worker_threads` can be made available with `--expose-internals`. - Rename `NativeModule.requireForDeps` to `NativeModule.requireWithFallbackInDeps`. - Add a test to make sure we do not accidentally leak any module to the global namespace. PR-URL: #25352 Reviewed-By: Anna Henningsen <anna@addaleax.net>
@addaleax
Copy link
Member

@joyeecheung Can you look into backporting this to v11.x-staging?

@BridgeAR
Copy link
Member

BridgeAR commented Jan 16, 2019

I pushed a backport directly onto v11.x-staging. There was just a minor conflict in lib/internal/bootstrap/loaders.js.

Seems like this requires a closer look.

@BridgeAR
Copy link
Member

This should be backported along #25481.

@BridgeAR BridgeAR mentioned this pull request Jan 16, 2019
2 tasks
@addaleax
Copy link
Member

antsmartian pushed a commit to antsmartian/node that referenced this pull request Feb 6, 2019
- Remove `NativeModule._source` - the compilation is now entirely done in C++ and `process.binding('natives')` is implemented directly in the binding loader so there is no need to store additional source code strings. - Instead of using an object as `NativeModule._cached` and insert into it after compilation of each native module, simply prebuild a JS map filled with all the native modules and infer the state of compilation through `mod.loading`/`mod.loaded`. - Rename `NativeModule.nonInternalExists` to `NativeModule.canBeRequiredByUsers` and precompute that property for all the native modules during bootstrap instead of branching in every require call during runtime. This also fixes the bug where `worker_threads` can be made available with `--expose-internals`. - Rename `NativeModule.requireForDeps` to `NativeModule.requireWithFallbackInDeps`. - Add a test to make sure we do not accidentally leak any module to the global namespace. PR-URL: nodejs#25352 Reviewed-By: Anna Henningsen <anna@addaleax.net>
addaleax pushed a commit that referenced this pull request Feb 9, 2019
- Remove `NativeModule._source` - the compilation is now entirely done in C++ and `process.binding('natives')` is implemented directly in the binding loader so there is no need to store additional source code strings. - Instead of using an object as `NativeModule._cached` and insert into it after compilation of each native module, simply prebuild a JS map filled with all the native modules and infer the state of compilation through `mod.loading`/`mod.loaded`. - Rename `NativeModule.nonInternalExists` to `NativeModule.canBeRequiredByUsers` and precompute that property for all the native modules during bootstrap instead of branching in every require call during runtime. This also fixes the bug where `worker_threads` can be made available with `--expose-internals`. - Rename `NativeModule.requireForDeps` to `NativeModule.requireWithFallbackInDeps`. - Add a test to make sure we do not accidentally leak any module to the global namespace. Backport-PR-URL: #25964 PR-URL: #25352 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. lib / src Issues and PRs related to general changes in the lib or src directory.

5 participants