Skip to content

Commit

Permalink
src: move process.binding('async_wrap') internal
Browse files Browse the repository at this point in the history
This commit makes the async_wrap builtin an internal builtin, and
changes usage of the builtin from using process.binding('async_wrap')
to use internalBinding instead.

Refs: #22160

PR-URL: #22469
Refs: #22160
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
danbev committed Aug 27, 2018
1 parent 49bfc37 commit da8641f
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 15 deletions.
3 changes: 2 additions & 1 deletion lib/internal/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const {
ERR_ASYNC_TYPE,
ERR_INVALID_ASYNC_ID
} = require('internal/errors').codes;
const async_wrap = process.binding('async_wrap');
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
* hooks for each type.
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@
'crypto',
'contextify',
'tcp_wrap',
'tls_wrap']);
'tls_wrap',
'async_wrap']);
process.binding = function binding(name) {
return internalBindingWhitelist.has(name) ?
internalBinding(name) :
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/crypto/pbkdf2.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

const { AsyncWrap, Providers } = process.binding('async_wrap');
const { Buffer } = require('buffer');
const { internalBinding } = require('internal/bootstrap/loaders');
const { AsyncWrap, Providers } = internalBinding('async_wrap');
const { Buffer } = require('buffer');
const { INT_MAX, pbkdf2: _pbkdf2 } = internalBinding('crypto');
const { validateInt32 } = require('internal/validators');
const {
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/crypto/random.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

const { AsyncWrap, Providers } = process.binding('async_wrap');
const { Buffer, kMaxLength } = require('buffer');
const { internalBinding } = require('internal/bootstrap/loaders');
const { AsyncWrap, Providers } = internalBinding('async_wrap');
const { Buffer, kMaxLength } = require('buffer');
const { randomBytes: _randomBytes } = internalBinding('crypto');
const {
ERR_INVALID_ARG_TYPE,
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/crypto/scrypt.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

const { AsyncWrap, Providers } = process.binding('async_wrap');
const { Buffer } = require('buffer');
const { internalBinding } = require('internal/bootstrap/loaders');
const { AsyncWrap, Providers } = internalBinding('async_wrap');
const { Buffer } = require('buffer');
const { INT_MAX, scrypt: _scrypt } = internalBinding('crypto');
const { validateInt32 } = require('internal/validators');
const {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/trace_events_async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { internalBinding } = require('internal/bootstrap/loaders');
const { trace } = internalBinding('trace_events');
const async_wrap = process.binding('async_wrap');
const async_wrap = internalBinding('async_wrap');
const async_hooks = require('async_hooks');
const { SafeMap, SafeSet } = require('internal/safe_globals');

Expand Down
2 changes: 1 addition & 1 deletion src/async_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -765,4 +765,4 @@ Local<Object> AsyncWrap::GetOwner(Environment* env, Local<Object> obj) {

} // namespace node

NODE_BUILTIN_MODULE_CONTEXT_AWARE(async_wrap, node::AsyncWrap::Initialize)
NODE_MODULE_CONTEXT_AWARE_INTERNAL(async_wrap, node::AsyncWrap::Initialize)
3 changes: 2 additions & 1 deletion test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ if (process.env.NODE_TEST_WITH_ASYNC_HOOKS) {
const destroydIdsList = {};
const destroyListList = {};
const initHandles = {};
const async_wrap = process.binding('async_wrap');
const { internalBinding } = require('internal/test/binding');
const async_wrap = internalBinding('async_wrap');

process.on('exit', () => {
// iterate through handles to make sure nothing crashes
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-async-wrap-destroyid.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Flags: --expose-internals
'use strict';

const common = require('../common');
const async_wrap = process.binding('async_wrap');
const { internalBinding } = require('internal/test/binding');
const async_wrap = internalBinding('async_wrap');
const assert = require('assert');
const async_hooks = require('async_hooks');
const RUNS = 5;
Expand Down
4 changes: 3 additions & 1 deletion test/pseudo-tty/test-async-wrap-getasyncid-tty.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Flags: --expose-internals --no-warnings
'use strict';

// see also test/sequential/test-async-wrap-getasyncid.js

const common = require('../common');
const assert = require('assert');
const tty_wrap = process.binding('tty_wrap');
const { TTYWRAP } = process.binding('async_wrap').Providers;
const { internalBinding } = require('internal/test/binding');
const { TTYWRAP } = internalBinding('async_wrap').Providers;
const providers = { TTYWRAP };

// Make sure that the TTYWRAP Provider is tested.
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-async-wrap-getasyncid.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const assert = require('assert');
const fs = require('fs');
const fsPromises = fs.promises;
const net = require('net');
const providers = Object.assign({}, process.binding('async_wrap').Providers);
const providers = Object.assign({}, internalBinding('async_wrap').Providers);
const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir');
const { getSystemErrorName } = require('util');
Expand Down
4 changes: 3 additions & 1 deletion test/sequential/test-inspector-async-call-stack.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
common.skipIf32Bits();

const assert = require('assert');
const async_wrap = process.binding('async_wrap');
const { internalBinding } = require('internal/test/binding');
const async_wrap = internalBinding('async_wrap');
const { kTotals } = async_wrap.constants;
const inspector = require('inspector');

Expand Down

0 comments on commit da8641f

Please sign in to comment.