Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
meta: merge node/master into node-chakracore/master
Browse files Browse the repository at this point in the history
Merge dbd1d1d as of 2018-02-09
This commit was automatically generated. For any problems, please contact jackhorton

Reviewed-By: Jimmy Thomson <jithomso@microsoft.com>
  • Loading branch information
chakrabot committed Feb 13, 2018
2 parents 63ce459 + dbd1d1d commit 3986ac3
Show file tree
Hide file tree
Showing 24 changed files with 263 additions and 85 deletions.
24 changes: 24 additions & 0 deletions benchmark/streams/pipe-object-mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';

const common = require('../common');
const { Readable, Writable } = require('stream');

const bench = common.createBenchmark(main, {
n: [5e6]
});

function main({ n }) {
const b = {};
const r = new Readable({ objectMode: true });
const w = new Writable({ objectMode: true });

var i = 0;

r._read = () => r.push(i++ === n ? null : b);
w._write = (data, enc, cb) => cb();

bench.start();

r.pipe(w);
w.on('finish', () => bench.end(n));
}
24 changes: 24 additions & 0 deletions benchmark/streams/pipe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';

const common = require('../common');
const { Readable, Writable } = require('stream');

const bench = common.createBenchmark(main, {
n: [5e6]
});

function main({ n }) {
const b = new Buffer(1024);
const r = new Readable();
const w = new Writable();

var i = 0;

r._read = () => r.push(i++ === n ? null : b);
w._write = (data, enc, cb) => cb();

bench.start();

r.pipe(w);
w.on('finish', () => bench.end(n));
}
8 changes: 6 additions & 2 deletions doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ changes:
description: Enumerable symbol properties are now compared.
- version: v9.0.0
pr-url: https://github.com/nodejs/node/pull/15036
description: NaN is now compared using the [SameValueZero][] comparison.
description: NaN is now compared using the
[SameValueZero](https://tc39.github.io/ecma262/#sec-samevaluezero)
comparison.
- version: v8.5.0
pr-url: https://github.com/nodejs/node/pull/15001
description: Error names and messages are now properly compared
Expand Down Expand Up @@ -615,7 +617,9 @@ changes:
description: -0 and +0 are not considered equal anymore.
- version: v9.0.0
pr-url: https://github.com/nodejs/node/pull/15036
description: NaN is now compared using the [SameValueZero][] comparison.
description: NaN is now compared using the
[SameValueZero](https://tc39.github.io/ecma262/#sec-samevaluezero)
comparison.
- version: v9.0.0
pr-url: https://github.com/nodejs/node/pull/15001
description: Error names and messages are now properly compared
Expand Down
7 changes: 5 additions & 2 deletions doc/api/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,9 @@ vulnerabilities. For the case when IV is reused in GCM, see [Nonce-Disrespecting
Adversaries][] for details.

### crypto.createCipheriv(algorithm, key, iv[, options])
<!-- YAML
added: v0.1.94
-->
- `algorithm` {string}
- `key` {string | Buffer | TypedArray | DataView}
- `iv` {string | Buffer | TypedArray | DataView}
Expand Down Expand Up @@ -1359,8 +1362,8 @@ recent OpenSSL releases, `openssl list-cipher-algorithms` will display the
available cipher algorithms.

The `key` is the raw key used by the `algorithm` and `iv` is an
[initialization vector][]. Both arguments must be `'utf8'` encoded strings or
[buffers][`Buffer`].
[initialization vector][]. Both arguments must be `'utf8'` encoded strings,
[Buffers][`Buffer`], `TypedArray`, or `DataView`s.

### crypto.createDiffieHellman(prime[, primeEncoding][, generator][, generatorEncoding])
<!-- YAML
Expand Down
9 changes: 9 additions & 0 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,15 @@ Type: Runtime
`timers.unenroll()` is deprecated. Please use the publicly documented [`clearTimeout()`][] or [`clearInterval()`][] instead.
<a id="DEP0097"></a>
### DEP0097: MakeCallback with domain property
Type: Runtime
Users of `MakeCallback` that add the `domain` property to carry context,
should start using the `async_context` variant of `MakeCallback` or
`CallbackScope`, or the the high-level `AsyncResource` class.
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array
Expand Down
2 changes: 1 addition & 1 deletion doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3388,7 +3388,7 @@ added: REPLACEME
Asynchronous fsync(2). The `Promise` is resolved with no arguments upon
success.

#### filehandle.truncate(len = 0)
#### filehandle.truncate(len)
<!-- YAML
added: REPLACEME
-->
Expand Down
34 changes: 15 additions & 19 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,17 @@ assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
}
};

function createMsg(msg, key, actual, expected) {
if (msg)
return msg;
return `${key}: expected ${inspect(expected[key])}, ` +
`not ${inspect(actual[key])}`;
function compareExceptionKey(actual, expected, key, msg) {
if (!isDeepStrictEqual(actual[key], expected[key])) {
innerFail({
actual: actual[key],
expected: expected[key],
message: msg || `${key}: expected ${inspect(expected[key])}, ` +
`not ${inspect(actual[key])}`,
operator: 'throws',
stackStartFn: assert.throws
});
}
}

function expectedException(actual, expected, msg) {
Expand All @@ -384,23 +390,13 @@ function expectedException(actual, expected, msg) {
// The name and message could be non enumerable. Therefore test them
// explicitly.
if ('name' in expected) {
assert.strictEqual(
actual.name,
expected.name,
createMsg(msg, 'name', actual, expected));
compareExceptionKey(actual, expected, 'name', msg);
}
if ('message' in expected) {
assert.strictEqual(
actual.message,
expected.message,
createMsg(msg, 'message', actual, expected));
compareExceptionKey(actual, expected, 'message', msg);
}
const keys = Object.keys(expected);
for (const key of keys) {
assert.deepStrictEqual(
actual[key],
expected[key],
createMsg(msg, key, actual, expected));
for (const key of Object.keys(expected)) {
compareExceptionKey(actual, expected, key, msg);
}
return true;
}
Expand Down
16 changes: 16 additions & 0 deletions lib/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,29 @@ process.setUncaughtExceptionCaptureCallback = function(fn) {
throw err;
};


let sendMakeCallbackDeprecation = false;
function emitMakeCallbackDeprecation() {
if (!sendMakeCallbackDeprecation) {
process.emitWarning(
'Using a domain property in MakeCallback is deprecated. Use the ' +
'async_context variant of MakeCallback or the AsyncResource class ' +
'instead.', 'DeprecationWarning', 'DEP0097');
sendMakeCallbackDeprecation = true;
}
}

function topLevelDomainCallback(cb, ...args) {
const domain = this.domain;
if (exports.active && domain)
emitMakeCallbackDeprecation();

if (domain)
domain.enter();
const ret = Reflect.apply(cb, this, args);
if (domain)
domain.exit();

return ret;
}

Expand Down
76 changes: 49 additions & 27 deletions lib/internal/process/next_tick.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,55 @@ function setupNextTick() {
const kHasScheduled = 0;
const kHasPromiseRejections = 1;

const nextTickQueue = {
head: null,
tail: null,
// Queue size for each tick array. Must be a factor of two.
const kQueueSize = 2048;
const kQueueMask = kQueueSize - 1;

class FixedQueue {
constructor() {
this.bottom = 0;
this.top = 0;
this.list = new Array(kQueueSize);
this.next = null;
}

push(data) {
const entry = { data, next: null };
if (this.tail !== null) {
this.tail.next = entry;
} else {
this.head = entry;
tickInfo[kHasScheduled] = 1;
}
this.tail = entry;
},
this.list[this.top] = data;
this.top = (this.top + 1) & kQueueMask;
}

shift() {
if (this.head === null)
return;
const ret = this.head.data;
if (this.head === this.tail) {
this.head = this.tail = null;
const next = this.list[this.bottom];
if (next === undefined) return null;
this.list[this.bottom] = undefined;
this.bottom = (this.bottom + 1) & kQueueMask;
return next;
}
}

var head = new FixedQueue();
var tail = head;

function push(data) {
if (head.bottom === head.top) {
if (head.list[head.top] !== undefined)
head = head.next = new FixedQueue();
else
tickInfo[kHasScheduled] = 1;
}
head.push(data);
}

function shift() {
const next = tail.shift();
if (tail.top === tail.bottom) {
if (tail.next)
tail = tail.next;
else
tickInfo[kHasScheduled] = 0;
} else {
this.head = this.head.next;
}
return ret;
}
};
return next;
}

process.nextTick = nextTick;
// Needs to be accessible from beyond this scope.
Expand All @@ -69,7 +92,7 @@ function setupNextTick() {
function _tickCallback() {
let tock;
do {
while (tock = nextTickQueue.shift()) {
while (tock = shift()) {
const asyncId = tock[async_id_symbol];
emitBefore(asyncId, tock[trigger_async_id_symbol]);
// emitDestroy() places the async_id_symbol into an asynchronous queue
Expand All @@ -93,7 +116,7 @@ function setupNextTick() {
emitAfter(asyncId);
}
runMicrotasks();
} while (nextTickQueue.head !== null || emitPromiseRejectionWarnings());
} while (head.top !== head.bottom || emitPromiseRejectionWarnings());
tickInfo[kHasPromiseRejections] = 0;
}

Expand Down Expand Up @@ -139,8 +162,7 @@ function setupNextTick() {
args[i - 1] = arguments[i];
}

nextTickQueue.push(new TickObject(callback, args,
getDefaultTriggerAsyncId()));
push(new TickObject(callback, args, getDefaultTriggerAsyncId()));
}

// `internalNextTick()` will not enqueue any callback when the process is
Expand Down Expand Up @@ -168,6 +190,6 @@ function setupNextTick() {

if (triggerAsyncId === null)
triggerAsyncId = getDefaultTriggerAsyncId();
nextTickQueue.push(new TickObject(callback, args, triggerAsyncId));
push(new TickObject(callback, args, triggerAsyncId));
}
}
9 changes: 0 additions & 9 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,6 @@ function writeAfterFIN(chunk, encoding, cb) {
}
}

Socket.prototype.read = function(n) {
if (n === 0)
return stream.Readable.prototype.read.call(this, n);

this.read = stream.Readable.prototype.read;
this._consuming = true;
return this.read(n);
};

Socket.prototype.setTimeout = function(msecs, callback) {
// Type checking identical to timers.enroll()
msecs = validateTimerDuration(msecs);
Expand Down
2 changes: 1 addition & 1 deletion test/addons-napi/test_make_callback/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ napi_value Init(napi_env env, napi_value exports) {
return exports;
}

} // namespace
} // anonymous namespace

NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)
2 changes: 1 addition & 1 deletion test/addons-napi/test_make_callback_recurse/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ napi_value Init(napi_env env, napi_value exports) {
return exports;
}

} // namespace
} // anonymous namespace

NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)
2 changes: 1 addition & 1 deletion test/addons/async-hooks-id/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ void Initialize(Local<Object> exports) {
NODE_SET_METHOD(exports, "getTriggerAsyncId", GetTriggerAsyncId);
}

} // namespace
} // anonymous namespace

NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)
2 changes: 1 addition & 1 deletion test/addons/async-resource/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,6 @@ void Initialize(Local<Object> exports) {
NODE_SET_METHOD(exports, "getResource", GetResource);
}

} // namespace
} // anonymous namespace

NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)
2 changes: 1 addition & 1 deletion test/addons/callback-scope/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ void Initialize(v8::Local<v8::Object> exports) {
NODE_SET_METHOD(exports, "testResolveAsync", TestResolveAsync);
}

} // namespace
} // anonymous namespace

NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)
Loading

0 comments on commit 3986ac3

Please sign in to comment.