summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-10-15 01:41:32 +0200
committerAnna Henningsen <anna@addaleax.net>2018-10-21 03:17:12 +0200
commit87b808f7611b5ed17164f939760f562d5af9fdb4 (patch)
tree2462cb1b292756df8f844891eeddd75edd81a084
parent20282b1cb0389553421c4c5b14de198c5dfff50b (diff)
downloadandroid-node-v8-87b808f7611b5ed17164f939760f562d5af9fdb4.tar.gz
android-node-v8-87b808f7611b5ed17164f939760f562d5af9fdb4.tar.bz2
android-node-v8-87b808f7611b5ed17164f939760f562d5af9fdb4.zip
src,lib: move `natives` and `constants` to `internalBinding()`
Refs: https://github.com/nodejs/node/issues/22160 PR-URL: https://github.com/nodejs/node/pull/23663 Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
-rw-r--r--lib/_tls_common.js2
-rw-r--r--lib/constants.js2
-rw-r--r--lib/crypto.js2
-rw-r--r--lib/dgram.js2
-rw-r--r--lib/fs.js2
-rw-r--r--lib/internal/bootstrap/loaders.js6
-rw-r--r--lib/internal/bootstrap/node.js4
-rw-r--r--lib/internal/crypto/cipher.js2
-rw-r--r--lib/internal/crypto/diffiehellman.js2
-rw-r--r--lib/internal/crypto/sig.js2
-rw-r--r--lib/internal/crypto/util.js2
-rw-r--r--lib/internal/fs/promises.js2
-rw-r--r--lib/internal/fs/utils.js2
-rw-r--r--lib/internal/process/main_thread_only.js2
-rw-r--r--lib/internal/process/per_thread.js2
-rw-r--r--lib/internal/util.js2
-rw-r--r--lib/internal/v8_prof_processor.js2
-rw-r--r--lib/os.js2
-rw-r--r--lib/tls.js2
-rw-r--r--lib/zlib.js2
-rw-r--r--src/node.cc16
21 files changed, 32 insertions, 30 deletions
diff --git a/lib/_tls_common.js b/lib/_tls_common.js
index b8e68eec15..2a88045067 100644
--- a/lib/_tls_common.js
+++ b/lib/_tls_common.js
@@ -29,7 +29,7 @@ const {
ERR_INVALID_ARG_TYPE
} = require('internal/errors').codes;
-const { SSL_OP_CIPHER_SERVER_PREFERENCE } = process.binding('constants').crypto;
+const { SSL_OP_CIPHER_SERVER_PREFERENCE } = internalBinding('constants').crypto;
// Lazily loaded from internal/crypto/util.
let toBuf = null;
diff --git a/lib/constants.js b/lib/constants.js
index a4c2ca6fb3..44c7388580 100644
--- a/lib/constants.js
+++ b/lib/constants.js
@@ -25,7 +25,7 @@
// towards using the specific constants exposed by the individual modules on
// which they are most relevant.
// Deprecation Code: DEP0008
-const constants = process.binding('constants');
+const constants = internalBinding('constants');
Object.assign(exports,
constants.os.dlopen,
constants.os.errno,
diff --git a/lib/crypto.js b/lib/crypto.js
index 6d7330134b..13987f9e03 100644
--- a/lib/crypto.js
+++ b/lib/crypto.js
@@ -34,7 +34,7 @@ const {
ERR_CRYPTO_FIPS_FORCED,
ERR_CRYPTO_FIPS_UNAVAILABLE
} = require('internal/errors').codes;
-const constants = process.binding('constants').crypto;
+const constants = internalBinding('constants').crypto;
const { getOptions } = internalBinding('options');
const pendingDeprecation = getOptions('--pending-deprecation');
const {
diff --git a/lib/dgram.js b/lib/dgram.js
index c4819f0eb0..549b6dd738 100644
--- a/lib/dgram.js
+++ b/lib/dgram.js
@@ -52,7 +52,7 @@ const {
defaultTriggerAsyncIdScope,
symbols: { async_id_symbol, owner_symbol }
} = require('internal/async_hooks');
-const { UV_UDP_REUSEADDR } = process.binding('constants').os;
+const { UV_UDP_REUSEADDR } = internalBinding('constants').os;
const { UDP, SendWrap } = internalBinding('udp_wrap');
diff --git a/lib/fs.js b/lib/fs.js
index 3302cfe0bf..bf964f5e99 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -24,7 +24,7 @@
'use strict';
-const { fs: constants } = process.binding('constants');
+const { fs: constants } = internalBinding('constants');
const {
S_IFIFO,
S_IFLNK,
diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js
index b3072a0294..dff6ce661a 100644
--- a/lib/internal/bootstrap/loaders.js
+++ b/lib/internal/bootstrap/loaders.js
@@ -123,7 +123,7 @@
this.script = null; // The ContextifyScript of the module
}
- NativeModule._source = getBinding('natives');
+ NativeModule._source = getInternalBinding('natives');
NativeModule._cache = {};
const config = getBinding('config');
@@ -256,12 +256,12 @@
// 1. `internalBinding('code_cache_hash')` must be in sync with
// `internalBinding('code_cache')` (same C++ file)
// 2. `internalBinding('natives_hash')` must be in sync with
- // `process.binding('natives')` (same C++ file)
+ // `internalBinding('natives')` (same C++ file)
// 3. If `internalBinding('natives_hash')` is in sync with
// `internalBinding('natives_hash')`, then the (unwrapped)
// code used to generate `internalBinding('code_cache')`
// should be in sync with the (unwrapped) code in
- // `process.binding('natives')`
+ // `internalBinding('natives')`
// There will be, however, false positives if the wrapper used
// to generate the cache is different from the one used at run time,
// and the length of the wrapper somehow stays the same.
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
index f53ed55dca..f0ca57afd4 100644
--- a/lib/internal/bootstrap/node.js
+++ b/lib/internal/bootstrap/node.js
@@ -414,7 +414,9 @@
'spawn_sync',
'js_stream',
'zlib',
- 'buffer']);
+ 'buffer',
+ 'natives',
+ 'constants']);
process.binding = function binding(name) {
return internalBindingWhitelist.has(name) ?
internalBinding(name) :
diff --git a/lib/internal/crypto/cipher.js b/lib/internal/crypto/cipher.js
index 2d7ddede57..a2e973ed84 100644
--- a/lib/internal/crypto/cipher.js
+++ b/lib/internal/crypto/cipher.js
@@ -3,7 +3,7 @@
const {
RSA_PKCS1_OAEP_PADDING,
RSA_PKCS1_PADDING
-} = process.binding('constants').crypto;
+} = internalBinding('constants').crypto;
const {
ERR_CRYPTO_INVALID_STATE,
diff --git a/lib/internal/crypto/diffiehellman.js b/lib/internal/crypto/diffiehellman.js
index 02142d4b1f..4f5bcbad97 100644
--- a/lib/internal/crypto/diffiehellman.js
+++ b/lib/internal/crypto/diffiehellman.js
@@ -24,7 +24,7 @@ const {
POINT_CONVERSION_COMPRESSED,
POINT_CONVERSION_HYBRID,
POINT_CONVERSION_UNCOMPRESSED
-} = process.binding('constants').crypto;
+} = internalBinding('constants').crypto;
const DH_GENERATOR = 2;
diff --git a/lib/internal/crypto/sig.js b/lib/internal/crypto/sig.js
index 86b43341bd..43033345af 100644
--- a/lib/internal/crypto/sig.js
+++ b/lib/internal/crypto/sig.js
@@ -9,7 +9,7 @@ const { Sign: _Sign, Verify: _Verify } = internalBinding('crypto');
const {
RSA_PSS_SALTLEN_AUTO,
RSA_PKCS1_PADDING
-} = process.binding('constants').crypto;
+} = internalBinding('constants').crypto;
const {
getDefaultEncoding,
kHandle,
diff --git a/lib/internal/crypto/util.js b/lib/internal/crypto/util.js
index 496f195c73..ff5bfce4a7 100644
--- a/lib/internal/crypto/util.js
+++ b/lib/internal/crypto/util.js
@@ -10,7 +10,7 @@ const {
const {
ENGINE_METHOD_ALL
-} = process.binding('constants').crypto;
+} = internalBinding('constants').crypto;
const {
ERR_CRYPTO_ENGINE_UNKNOWN,
diff --git a/lib/internal/fs/promises.js b/lib/internal/fs/promises.js
index 6cae7d1a21..0fecb20623 100644
--- a/lib/internal/fs/promises.js
+++ b/lib/internal/fs/promises.js
@@ -6,7 +6,7 @@ const {
O_WRONLY,
S_IFMT,
S_IFREG
-} = process.binding('constants').fs;
+} = internalBinding('constants').fs;
const binding = process.binding('fs');
const { Buffer, kMaxLength } = require('buffer');
const {
diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js
index c614cb4880..0df13354ac 100644
--- a/lib/internal/fs/utils.js
+++ b/lib/internal/fs/utils.js
@@ -43,7 +43,7 @@ const {
UV_DIRENT_SOCKET,
UV_DIRENT_CHAR,
UV_DIRENT_BLOCK
-} = process.binding('constants').fs;
+} = internalBinding('constants').fs;
const isWindows = process.platform === 'win32';
diff --git a/lib/internal/process/main_thread_only.js b/lib/internal/process/main_thread_only.js
index 49910fafd7..b8e518f6a1 100644
--- a/lib/internal/process/main_thread_only.js
+++ b/lib/internal/process/main_thread_only.js
@@ -118,7 +118,7 @@ function setupPosixMethods(_initgroups, _setegid, _seteuid,
// Worker threads don't receive signals.
function setupSignalHandlers(internalBinding) {
- const constants = process.binding('constants').os.signals;
+ const constants = internalBinding('constants').os.signals;
const signalWraps = Object.create(null);
let Signal;
diff --git a/lib/internal/process/per_thread.js b/lib/internal/process/per_thread.js
index 9397ce3f59..fa3421a3a3 100644
--- a/lib/internal/process/per_thread.js
+++ b/lib/internal/process/per_thread.js
@@ -17,7 +17,7 @@ const {
}
} = require('internal/errors');
const util = require('util');
-const constants = process.binding('constants').os.signals;
+const constants = internalBinding('constants').os.signals;
const { deprecate } = require('internal/util');
function setupAssert() {
diff --git a/lib/internal/util.js b/lib/internal/util.js
index 745b69381d..3524b9e1d6 100644
--- a/lib/internal/util.js
+++ b/lib/internal/util.js
@@ -5,7 +5,7 @@ const {
ERR_NO_CRYPTO,
ERR_UNKNOWN_SIGNAL
} = require('internal/errors').codes;
-const { signals } = process.binding('constants').os;
+const { signals } = internalBinding('constants').os;
const {
getHiddenValue,
setHiddenValue,
diff --git a/lib/internal/v8_prof_processor.js b/lib/internal/v8_prof_processor.js
index 6c7a4db664..572b8074c4 100644
--- a/lib/internal/v8_prof_processor.js
+++ b/lib/internal/v8_prof_processor.js
@@ -19,7 +19,7 @@ const scriptFiles = [
var script = '';
scriptFiles.forEach(function(s) {
- script += process.binding('natives')[s] + '\n';
+ script += internalBinding('natives')[s] + '\n';
});
const tickArguments = [];
diff --git a/lib/os.js b/lib/os.js
index 86a24b7c62..797201c4b5 100644
--- a/lib/os.js
+++ b/lib/os.js
@@ -22,7 +22,7 @@
'use strict';
const { pushValToArrayMax, safeGetenv } = internalBinding('util');
-const constants = process.binding('constants').os;
+const constants = internalBinding('constants').os;
const { deprecate } = require('internal/util');
const isWindows = process.platform === 'win32';
diff --git a/lib/tls.js b/lib/tls.js
index 57228ca273..3335632c93 100644
--- a/lib/tls.js
+++ b/lib/tls.js
@@ -46,7 +46,7 @@ exports.CLIENT_RENEG_LIMIT = 3;
exports.CLIENT_RENEG_WINDOW = 600;
exports.DEFAULT_CIPHERS =
- process.binding('constants').crypto.defaultCipherList;
+ internalBinding('constants').crypto.defaultCipherList;
exports.DEFAULT_ECDH_CURVE = 'auto';
diff --git a/lib/zlib.js b/lib/zlib.js
index c97da5dd30..61f57429d6 100644
--- a/lib/zlib.js
+++ b/lib/zlib.js
@@ -45,7 +45,7 @@ const {
} = require('buffer');
const { owner_symbol } = require('internal/async_hooks').symbols;
-const constants = process.binding('constants').zlib;
+const constants = internalBinding('constants').zlib;
const {
Z_NO_FLUSH, Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, Z_FULL_FLUSH, Z_FINISH,
Z_MIN_CHUNK, Z_MIN_WINDOWBITS, Z_MAX_WINDOWBITS, Z_MIN_LEVEL, Z_MAX_LEVEL,
diff --git a/src/node.cc b/src/node.cc
index bab251ada3..c24dfce0ab 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -1542,14 +1542,6 @@ static void GetBinding(const FunctionCallbackInfo<Value>& args) {
Local<Object> exports;
if (mod != nullptr) {
exports = InitModule(env, mod, module);
- } else if (!strcmp(*module_v, "constants")) {
- exports = Object::New(env->isolate());
- CHECK(exports->SetPrototype(env->context(),
- Null(env->isolate())).FromJust());
- DefineConstants(env->isolate(), exports);
- } else if (!strcmp(*module_v, "natives")) {
- exports = Object::New(env->isolate());
- DefineJavaScript(env, exports);
} else {
return ThrowIfNoSuchModule(env, *module_v);
}
@@ -1569,6 +1561,14 @@ static void GetInternalBinding(const FunctionCallbackInfo<Value>& args) {
node_module* mod = get_internal_module(*module_v);
if (mod != nullptr) {
exports = InitModule(env, mod, module);
+ } else if (!strcmp(*module_v, "constants")) {
+ exports = Object::New(env->isolate());
+ CHECK(exports->SetPrototype(env->context(),
+ Null(env->isolate())).FromJust());
+ DefineConstants(env->isolate(), exports);
+ } else if (!strcmp(*module_v, "natives")) {
+ exports = Object::New(env->isolate());
+ DefineJavaScript(env, exports);
} else if (!strcmp(*module_v, "code_cache")) {
// internalBinding('code_cache')
exports = Object::New(env->isolate());