Skip to content
Permalink
Browse files

bootstrapper: move internalBinding to NativeModule

internalBinding is used so often that it should just automatically be
available for usage in internals.

PR-URL: #23025
Refs: 2a9eb31
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information...
devsnek authored and jasnell committed Sep 22, 2018
1 parent 87d801c commit 0d548924b043a08b90c2e91837e8b99af199ccb2
Showing with 6 additions and 74 deletions.
  1. +1 −0 lib/.eslintrc.yaml
  2. +0 −1 lib/_http_client.js
  3. +0 −1 lib/_http_common.js
  4. +0 −1 lib/_http_server.js
  5. +0 −1 lib/_tls_common.js
  6. +0 −1 lib/_tls_wrap.js
  7. +0 −1 lib/buffer.js
  8. +0 −1 lib/child_process.js
  9. +0 −1 lib/console.js
  10. +0 −1 lib/crypto.js
  11. +0 −1 lib/dgram.js
  12. +0 −1 lib/dns.js
  13. +0 −1 lib/domain.js
  14. +0 −1 lib/internal/async_hooks.js
  15. +0 −1 lib/internal/bash_completion.js
  16. +2 −2 lib/internal/bootstrap/loaders.js
  17. +0 −1 lib/internal/child_process.js
  18. +0 −1 lib/internal/cluster/round_robin_handle.js
  19. +0 −1 lib/internal/crypto/certificate.js
  20. +0 −1 lib/internal/crypto/cipher.js
  21. +0 −1 lib/internal/crypto/keygen.js
  22. +0 −1 lib/internal/crypto/pbkdf2.js
  23. +0 −1 lib/internal/crypto/random.js
  24. +0 −1 lib/internal/crypto/scrypt.js
  25. +0 −1 lib/internal/crypto/sig.js
  26. +0 −1 lib/internal/crypto/util.js
  27. +0 −1 lib/internal/dgram.js
  28. +0 −1 lib/internal/dns/promises.js
  29. +0 −1 lib/internal/dns/utils.js
  30. +0 −1 lib/internal/domexception.js
  31. +0 −1 lib/internal/encoding.js
  32. +0 −1 lib/internal/errors.js
  33. +0 −1 lib/internal/fs/watchers.js
  34. +0 −1 lib/internal/http2/compat.js
  35. +0 −1 lib/internal/http2/core.js
  36. +0 −1 lib/internal/http2/util.js
  37. +1 −1 lib/internal/modules/cjs/loader.js
  38. +0 −1 lib/internal/modules/esm/create_dynamic_module.js
  39. +1 −1 lib/internal/modules/esm/default_resolve.js
  40. +0 −1 lib/internal/modules/esm/module_job.js
  41. +1 −1 lib/internal/modules/esm/translators.js
  42. +0 −1 lib/internal/print_help.js
  43. +0 −1 lib/internal/process/esm_loader.js
  44. +0 −1 lib/internal/process/promises.js
  45. +0 −2 lib/internal/process/stdio.js
  46. +0 −1 lib/internal/queue_microtask.js
  47. +0 −1 lib/internal/stream_base_commons.js
  48. +0 −1 lib/internal/test/binding.js
  49. +0 −1 lib/internal/test/heap.js
  50. +0 −1 lib/internal/timers.js
  51. +0 −1 lib/internal/trace_events_async_hooks.js
  52. +0 −1 lib/internal/url.js
  53. +0 −1 lib/internal/util.js
  54. +0 −1 lib/internal/util/comparisons.js
  55. +0 −2 lib/internal/util/inspect.js
  56. +0 −1 lib/internal/vm/source_text_module.js
  57. +0 −1 lib/internal/worker.js
  58. +0 −1 lib/internal/wrap_js_stream.js
  59. +0 −1 lib/net.js
  60. +0 −1 lib/os.js
  61. +0 −1 lib/perf_hooks.js
  62. +0 −1 lib/repl.js
  63. +0 −1 lib/stream.js
  64. +0 −1 lib/string_decoder.js
  65. +0 −1 lib/timers.js
  66. +0 −1 lib/tls.js
  67. +0 −1 lib/trace_events.js
  68. +0 −1 lib/tty.js
  69. +0 −2 lib/util.js
  70. +0 −1 lib/v8.js
  71. +0 −1 lib/vm.js
@@ -44,3 +44,4 @@ globals:
DCHECK_LE: false
DCHECK_LT: false
DCHECK_NE: false
internalBinding: false
@@ -24,7 +24,6 @@
const util = require('util');
const net = require('net');
const url = require('url');
const { internalBinding } = require('internal/bootstrap/loaders');
const { HTTPParser } = internalBinding('http_parser');
const assert = require('assert').ok;
const {
@@ -21,7 +21,6 @@

'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const { methods, HTTPParser } = internalBinding('http_parser');

const FreeList = require('internal/freelist');
@@ -23,7 +23,6 @@

const util = require('util');
const net = require('net');
const { internalBinding } = require('internal/bootstrap/loaders');
const { HTTPParser } = internalBinding('http_parser');
const assert = require('assert').ok;
const {
@@ -34,7 +34,6 @@ const { SSL_OP_CIPHER_SERVER_PREFERENCE } = process.binding('constants').crypto;
// Lazily loaded from internal/crypto/util.
let toBuf = null;

const { internalBinding } = require('internal/bootstrap/loaders');
const { SecureContext: NativeSecureContext } = internalBinding('crypto');
function SecureContext(secureProtocol, secureOptions, context) {
if (!(this instanceof SecureContext)) {
@@ -32,7 +32,6 @@ const common = require('_tls_common');
const { StreamWrap } = require('_stream_wrap');
const { Buffer } = require('buffer');
const debug = util.debuglog('tls');
const { internalBinding } = require('internal/bootstrap/loaders');
const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap');
const tls_wrap = internalBinding('tls_wrap');
const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap');
@@ -41,7 +41,6 @@ const {
// that test/parallel/test-buffer-bindingobj-no-zerofill.js is written.
let isAnyArrayBuffer;
try {
const { internalBinding } = require('internal/bootstrap/loaders');
isAnyArrayBuffer = internalBinding('types').isAnyArrayBuffer;
} catch (e) {
isAnyArrayBuffer = require('util').types.isAnyArrayBuffer;
@@ -28,7 +28,6 @@ const {
const { isArrayBufferView } = require('internal/util/types');
const debug = util.debuglog('child_process');
const { Buffer } = require('buffer');
const { internalBinding } = require('internal/bootstrap/loaders');
const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap');
const {
ERR_INVALID_ARG_VALUE,
@@ -29,7 +29,6 @@ const {
ERR_INVALID_ARG_VALUE,
},
} = require('internal/errors');
const { internalBinding } = require('internal/bootstrap/loaders');
const { previewEntries } = internalBinding('util');
const { Buffer: { isBuffer } } = require('buffer');
const util = require('util');
@@ -30,7 +30,6 @@ const {
} = require('internal/util');
assertCrypto();

const { internalBinding } = require('internal/bootstrap/loaders');
const {
ERR_CRYPTO_FIPS_FORCED,
ERR_CRYPTO_FIPS_UNAVAILABLE
@@ -52,7 +52,6 @@ const {
defaultTriggerAsyncIdScope,
symbols: { async_id_symbol, owner_symbol }
} = require('internal/async_hooks');
const { internalBinding } = require('internal/bootstrap/loaders');
const { UV_UDP_REUSEADDR } = process.binding('constants').os;

const { UDP, SendWrap } = internalBinding('udp_wrap');
@@ -21,7 +21,6 @@

'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const cares = internalBinding('cares_wrap');
const { isIP, isIPv4, isLegalPort } = require('internal/net');
const { customPromisifyArgs } = require('internal/util');
@@ -34,7 +34,6 @@ const {
ERR_UNHANDLED_ERROR
} = require('internal/errors').codes;
const { createHook } = require('async_hooks');
const { internalBinding } = require('internal/bootstrap/loaders');

// overwrite process.domain with a getter/setter that will allow for more
// effective optimizations
@@ -4,7 +4,6 @@ const {
ERR_ASYNC_TYPE,
ERR_INVALID_ASYNC_ID
} = require('internal/errors').codes;
const { internalBinding } = require('internal/bootstrap/loaders');
const async_wrap = internalBinding('async_wrap');
/* async_hook_fields is a Uint32Array wrapping the uint32_t array of
* Environment::AsyncHooks::fields_[]. Each index tracks the number of active
@@ -1,5 +1,4 @@
'use strict';
const { internalBinding } = require('internal/bootstrap/loaders');
const { getOptions } = internalBinding('options');

function print(stream) {
@@ -223,7 +223,7 @@
};

NativeModule.wrapper = [
'(function (exports, require, module, process) {',
'(function (exports, require, module, process, internalBinding) {',
'\n});'
];

@@ -294,7 +294,7 @@
const requireFn = this.id.startsWith('internal/deps/') ?
NativeModule.requireForDeps :
NativeModule.require;
fn(this.exports, requireFn, this, process);
fn(this.exports, requireFn, this, process, internalBinding);

if (config.experimentalModules && !NativeModule.isInternal(this.id)) {
this.exportKeys = ObjectKeys(this.exports);
@@ -21,7 +21,6 @@ const dgram = require('dgram');
const util = require('util');
const assert = require('assert');

const { internalBinding } = require('internal/bootstrap/loaders');
const { Process } = internalBinding('process_wrap');
const { WriteWrap } = internalBinding('stream_wrap');
const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap');
@@ -2,7 +2,6 @@
const assert = require('assert');
const net = require('net');
const { sendHelper } = require('internal/cluster/utils');
const { internalBinding } = require('internal/bootstrap/loaders');
const uv = internalBinding('uv');

module.exports = RoundRobinHandle;
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const {
certExportChallenge,
certExportPublicKey,
@@ -21,7 +21,6 @@ const {

const { isArrayBufferView } = require('internal/util/types');

const { internalBinding } = require('internal/bootstrap/loaders');
const {
CipherBase,
privateDecrypt: _privateDecrypt,
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const { AsyncWrap, Providers } = internalBinding('async_wrap');
const {
generateKeyPairRSA,
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const { AsyncWrap, Providers } = internalBinding('async_wrap');
const { Buffer } = require('buffer');
const { pbkdf2: _pbkdf2 } = internalBinding('crypto');
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const { AsyncWrap, Providers } = internalBinding('async_wrap');
const { Buffer, kMaxLength } = require('buffer');
const { randomBytes: _randomBytes } = internalBinding('crypto');
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const { AsyncWrap, Providers } = internalBinding('async_wrap');
const { Buffer } = require('buffer');
const { scrypt: _scrypt } = internalBinding('crypto');
@@ -5,7 +5,6 @@ const {
ERR_INVALID_OPT_VALUE
} = require('internal/errors').codes;
const { validateString } = require('internal/validators');
const { internalBinding } = require('internal/bootstrap/loaders');
const { Sign: _Sign, Verify: _Verify } = internalBinding('crypto');
const {
RSA_PSS_SALTLEN_AUTO,
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const {
getCiphers: _getCiphers,
getCurves: _getCurves,
@@ -1,6 +1,5 @@
'use strict';
const { codes } = require('internal/errors');
const { internalBinding } = require('internal/bootstrap/loaders');
const { UDP } = internalBinding('udp_wrap');
const { isInt32 } = require('internal/validators');
const TTYWrap = internalBinding('tty_wrap');
@@ -6,7 +6,6 @@ const {
} = require('internal/dns/utils');
const { codes, dnsException } = require('internal/errors');
const { isIP, isIPv4, isLegalPort } = require('internal/net');
const { internalBinding } = require('internal/bootstrap/loaders');
const {
getaddrinfo,
getnameinfo,
@@ -1,7 +1,6 @@
'use strict';
const errors = require('internal/errors');
const { isIP } = require('internal/net');
const { internalBinding } = require('internal/bootstrap/loaders');
const {
ChannelWrap,
strerror,
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const { registerDOMException } = internalBinding('messaging');
const { ERR_INVALID_THIS } = require('internal/errors').codes;

@@ -23,7 +23,6 @@ const {

const { isArrayBufferView } = require('internal/util/types');

const { internalBinding } = require('internal/bootstrap/loaders');
const {
isArrayBuffer
} = internalBinding('types');
@@ -15,7 +15,6 @@ const kInfo = Symbol('info');
const messages = new Map();
const codes = {};

const { internalBinding } = require('internal/bootstrap/loaders');
const {
errmap,
UV_EAI_NODATA,
@@ -1,7 +1,6 @@
'use strict';

const errors = require('internal/errors');
const { internalBinding } = require('internal/bootstrap/loaders');
const {
kFsStatsFieldsLength,
StatWatcher: _StatWatcher
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const Stream = require('stream');
const Readable = Stream.Readable;
const binding = internalBinding('http2');
@@ -10,7 +10,6 @@ const {

assertCrypto();

const { internalBinding } = require('internal/bootstrap/loaders');
const assert = require('assert');
const EventEmitter = require('events');
const fs = require('fs');
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const binding = internalBinding('http2');
const {
ERR_HTTP2_HEADER_SINGLE_VALUE,
@@ -21,7 +21,7 @@

'use strict';

const { internalBinding, NativeModule } = require('internal/bootstrap/loaders');
const { NativeModule } = require('internal/bootstrap/loaders');
const util = require('util');
const { pathToFileURL } = require('internal/url');
const vm = require('vm');
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const { ModuleWrap } = internalBinding('module_wrap');
const debug = require('util').debuglog('esm');
const ArrayJoin = Function.call.bind(Array.prototype.join);
@@ -3,7 +3,7 @@
const { URL } = require('url');
const CJSmodule = require('internal/modules/cjs/loader');
const internalFS = require('internal/fs/utils');
const { NativeModule, internalBinding } = require('internal/bootstrap/loaders');
const { NativeModule } = require('internal/bootstrap/loaders');
const { extname } = require('path');
const { realpathSync } = require('fs');
const preserveSymlinks = !!process.binding('config').preserveSymlinks;
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const { ModuleWrap } = internalBinding('module_wrap');
const { SafeSet, SafePromise } = require('internal/safe_globals');
const { decorateErrorStack } = require('internal/util');
@@ -1,6 +1,6 @@
'use strict';

const { NativeModule, internalBinding } = require('internal/bootstrap/loaders');
const { NativeModule } = require('internal/bootstrap/loaders');
const { ModuleWrap } = internalBinding('module_wrap');
const {
stripShebang,
@@ -1,5 +1,4 @@
'use strict';
const { internalBinding } = require('internal/bootstrap/loaders');
const { getOptions, types } = internalBinding('options');

const typeLookup = [];
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const {
setImportModuleDynamicallyCallback,
setInitializeImportMetaObjectCallback
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const { safeToString } = internalBinding('util');

const maybeUnhandledPromises = new WeakMap();
@@ -47,7 +47,6 @@ function getMainThreadStdio() {

function getStdin() {
if (stdin) return stdin;
const { internalBinding } = require('internal/bootstrap/loaders');
const tty_wrap = internalBinding('tty_wrap');
const fd = 0;

@@ -164,7 +163,6 @@ function setupProcessStdio({ getStdout, getStdin, getStderr }) {

function createWritableStdioStream(fd) {
var stream;
const { internalBinding } = require('internal/bootstrap/loaders');
const tty_wrap = internalBinding('tty_wrap');

// Note stream._type is used for test-module-load-list.js
@@ -3,7 +3,6 @@
const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes;
const { AsyncResource } = require('async_hooks');
const { getDefaultTriggerAsyncId } = require('internal/async_hooks');
const { internalBinding } = require('internal/bootstrap/loaders');
const { enqueueMicrotask } = internalBinding('util');

// declared separately for name, arrow function to prevent construction
@@ -1,7 +1,6 @@
'use strict';

const { Buffer } = require('buffer');
const { internalBinding } = require('internal/bootstrap/loaders');
const { WriteWrap } = internalBinding('stream_wrap');
const { UV_EOF } = internalBinding('uv');
const { errnoException } = require('internal/errors');
@@ -5,5 +5,4 @@ process.emitWarning(
'tracked by any versioning system or deprecation process.',
'internal/test/binding');

const { internalBinding } = require('internal/bootstrap/loaders');
module.exports = { internalBinding };
@@ -5,7 +5,6 @@ process.emitWarning(
'tracked by any versioning system or deprecation process.',
'internal/test/heap');

const { internalBinding } = require('internal/bootstrap/loaders');
const { createHeapDump, buildEmbedderGraph } = internalBinding('heap_utils');
const assert = require('assert');

@@ -6,7 +6,6 @@ const {
initHooksExist,
emitInit
} = require('internal/async_hooks');
const { internalBinding } = require('internal/bootstrap/loaders');
// Symbols for storing async id state.
const async_id_symbol = Symbol('asyncId');
const trigger_async_id_symbol = Symbol('triggerId');

0 comments on commit 0d54892

Please sign in to comment.
You can’t perform that action at this time.