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

Commit 3986ac3

Browse files
committed
meta: merge node/master into node-chakracore/master
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>
2 parents 63ce459 + dbd1d1d commit 3986ac3

File tree

24 files changed

+263
-85
lines changed

24 files changed

+263
-85
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const { Readable, Writable } = require('stream');
5+
6+
const bench = common.createBenchmark(main, {
7+
n: [5e6]
8+
});
9+
10+
function main({ n }) {
11+
const b = {};
12+
const r = new Readable({ objectMode: true });
13+
const w = new Writable({ objectMode: true });
14+
15+
var i = 0;
16+
17+
r._read = () => r.push(i++ === n ? null : b);
18+
w._write = (data, enc, cb) => cb();
19+
20+
bench.start();
21+
22+
r.pipe(w);
23+
w.on('finish', () => bench.end(n));
24+
}

benchmark/streams/pipe.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const { Readable, Writable } = require('stream');
5+
6+
const bench = common.createBenchmark(main, {
7+
n: [5e6]
8+
});
9+
10+
function main({ n }) {
11+
const b = new Buffer(1024);
12+
const r = new Readable();
13+
const w = new Writable();
14+
15+
var i = 0;
16+
17+
r._read = () => r.push(i++ === n ? null : b);
18+
w._write = (data, enc, cb) => cb();
19+
20+
bench.start();
21+
22+
r.pipe(w);
23+
w.on('finish', () => bench.end(n));
24+
}

doc/api/assert.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ changes:
208208
description: Enumerable symbol properties are now compared.
209209
- version: v9.0.0
210210
pr-url: https://github.com/nodejs/node/pull/15036
211-
description: NaN is now compared using the [SameValueZero][] comparison.
211+
description: NaN is now compared using the
212+
[SameValueZero](https://tc39.github.io/ecma262/#sec-samevaluezero)
213+
comparison.
212214
- version: v8.5.0
213215
pr-url: https://github.com/nodejs/node/pull/15001
214216
description: Error names and messages are now properly compared
@@ -615,7 +617,9 @@ changes:
615617
description: -0 and +0 are not considered equal anymore.
616618
- version: v9.0.0
617619
pr-url: https://github.com/nodejs/node/pull/15036
618-
description: NaN is now compared using the [SameValueZero][] comparison.
620+
description: NaN is now compared using the
621+
[SameValueZero](https://tc39.github.io/ecma262/#sec-samevaluezero)
622+
comparison.
619623
- version: v9.0.0
620624
pr-url: https://github.com/nodejs/node/pull/15001
621625
description: Error names and messages are now properly compared

doc/api/crypto.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,9 @@ vulnerabilities. For the case when IV is reused in GCM, see [Nonce-Disrespecting
12841284
Adversaries][] for details.
12851285

12861286
### crypto.createCipheriv(algorithm, key, iv[, options])
1287+
<!-- YAML
1288+
added: v0.1.94
1289+
-->
12871290
- `algorithm` {string}
12881291
- `key` {string | Buffer | TypedArray | DataView}
12891292
- `iv` {string | Buffer | TypedArray | DataView}
@@ -1359,8 +1362,8 @@ recent OpenSSL releases, `openssl list-cipher-algorithms` will display the
13591362
available cipher algorithms.
13601363

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

13651368
### crypto.createDiffieHellman(prime[, primeEncoding][, generator][, generatorEncoding])
13661369
<!-- YAML

doc/api/deprecations.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,15 @@ Type: Runtime
871871
872872
`timers.unenroll()` is deprecated. Please use the publicly documented [`clearTimeout()`][] or [`clearInterval()`][] instead.
873873
874+
<a id="DEP0097"></a>
875+
### DEP0097: MakeCallback with domain property
876+
877+
Type: Runtime
878+
879+
Users of `MakeCallback` that add the `domain` property to carry context,
880+
should start using the `async_context` variant of `MakeCallback` or
881+
`CallbackScope`, or the the high-level `AsyncResource` class.
882+
874883
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
875884
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
876885
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array

doc/api/fs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3388,7 +3388,7 @@ added: REPLACEME
33883388
Asynchronous fsync(2). The `Promise` is resolved with no arguments upon
33893389
success.
33903390

3391-
#### filehandle.truncate(len = 0)
3391+
#### filehandle.truncate(len)
33923392
<!-- YAML
33933393
added: REPLACEME
33943394
-->

lib/assert.js

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,17 @@ assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
365365
}
366366
};
367367

368-
function createMsg(msg, key, actual, expected) {
369-
if (msg)
370-
return msg;
371-
return `${key}: expected ${inspect(expected[key])}, ` +
372-
`not ${inspect(actual[key])}`;
368+
function compareExceptionKey(actual, expected, key, msg) {
369+
if (!isDeepStrictEqual(actual[key], expected[key])) {
370+
innerFail({
371+
actual: actual[key],
372+
expected: expected[key],
373+
message: msg || `${key}: expected ${inspect(expected[key])}, ` +
374+
`not ${inspect(actual[key])}`,
375+
operator: 'throws',
376+
stackStartFn: assert.throws
377+
});
378+
}
373379
}
374380

375381
function expectedException(actual, expected, msg) {
@@ -384,23 +390,13 @@ function expectedException(actual, expected, msg) {
384390
// The name and message could be non enumerable. Therefore test them
385391
// explicitly.
386392
if ('name' in expected) {
387-
assert.strictEqual(
388-
actual.name,
389-
expected.name,
390-
createMsg(msg, 'name', actual, expected));
393+
compareExceptionKey(actual, expected, 'name', msg);
391394
}
392395
if ('message' in expected) {
393-
assert.strictEqual(
394-
actual.message,
395-
expected.message,
396-
createMsg(msg, 'message', actual, expected));
396+
compareExceptionKey(actual, expected, 'message', msg);
397397
}
398-
const keys = Object.keys(expected);
399-
for (const key of keys) {
400-
assert.deepStrictEqual(
401-
actual[key],
402-
expected[key],
403-
createMsg(msg, key, actual, expected));
398+
for (const key of Object.keys(expected)) {
399+
compareExceptionKey(actual, expected, key, msg);
404400
}
405401
return true;
406402
}

lib/domain.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,29 @@ process.setUncaughtExceptionCaptureCallback = function(fn) {
9494
throw err;
9595
};
9696

97+
98+
let sendMakeCallbackDeprecation = false;
99+
function emitMakeCallbackDeprecation() {
100+
if (!sendMakeCallbackDeprecation) {
101+
process.emitWarning(
102+
'Using a domain property in MakeCallback is deprecated. Use the ' +
103+
'async_context variant of MakeCallback or the AsyncResource class ' +
104+
'instead.', 'DeprecationWarning', 'DEP0097');
105+
sendMakeCallbackDeprecation = true;
106+
}
107+
}
108+
97109
function topLevelDomainCallback(cb, ...args) {
98110
const domain = this.domain;
111+
if (exports.active && domain)
112+
emitMakeCallbackDeprecation();
113+
99114
if (domain)
100115
domain.enter();
101116
const ret = Reflect.apply(cb, this, args);
102117
if (domain)
103118
domain.exit();
119+
104120
return ret;
105121
}
106122

lib/internal/process/next_tick.js

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,55 @@ function setupNextTick() {
3232
const kHasScheduled = 0;
3333
const kHasPromiseRejections = 1;
3434

35-
const nextTickQueue = {
36-
head: null,
37-
tail: null,
35+
// Queue size for each tick array. Must be a factor of two.
36+
const kQueueSize = 2048;
37+
const kQueueMask = kQueueSize - 1;
38+
39+
class FixedQueue {
40+
constructor() {
41+
this.bottom = 0;
42+
this.top = 0;
43+
this.list = new Array(kQueueSize);
44+
this.next = null;
45+
}
46+
3847
push(data) {
39-
const entry = { data, next: null };
40-
if (this.tail !== null) {
41-
this.tail.next = entry;
42-
} else {
43-
this.head = entry;
44-
tickInfo[kHasScheduled] = 1;
45-
}
46-
this.tail = entry;
47-
},
48+
this.list[this.top] = data;
49+
this.top = (this.top + 1) & kQueueMask;
50+
}
51+
4852
shift() {
49-
if (this.head === null)
50-
return;
51-
const ret = this.head.data;
52-
if (this.head === this.tail) {
53-
this.head = this.tail = null;
53+
const next = this.list[this.bottom];
54+
if (next === undefined) return null;
55+
this.list[this.bottom] = undefined;
56+
this.bottom = (this.bottom + 1) & kQueueMask;
57+
return next;
58+
}
59+
}
60+
61+
var head = new FixedQueue();
62+
var tail = head;
63+
64+
function push(data) {
65+
if (head.bottom === head.top) {
66+
if (head.list[head.top] !== undefined)
67+
head = head.next = new FixedQueue();
68+
else
69+
tickInfo[kHasScheduled] = 1;
70+
}
71+
head.push(data);
72+
}
73+
74+
function shift() {
75+
const next = tail.shift();
76+
if (tail.top === tail.bottom) {
77+
if (tail.next)
78+
tail = tail.next;
79+
else
5480
tickInfo[kHasScheduled] = 0;
55-
} else {
56-
this.head = this.head.next;
57-
}
58-
return ret;
5981
}
60-
};
82+
return next;
83+
}
6184

6285
process.nextTick = nextTick;
6386
// Needs to be accessible from beyond this scope.
@@ -69,7 +92,7 @@ function setupNextTick() {
6992
function _tickCallback() {
7093
let tock;
7194
do {
72-
while (tock = nextTickQueue.shift()) {
95+
while (tock = shift()) {
7396
const asyncId = tock[async_id_symbol];
7497
emitBefore(asyncId, tock[trigger_async_id_symbol]);
7598
// emitDestroy() places the async_id_symbol into an asynchronous queue
@@ -93,7 +116,7 @@ function setupNextTick() {
93116
emitAfter(asyncId);
94117
}
95118
runMicrotasks();
96-
} while (nextTickQueue.head !== null || emitPromiseRejectionWarnings());
119+
} while (head.top !== head.bottom || emitPromiseRejectionWarnings());
97120
tickInfo[kHasPromiseRejections] = 0;
98121
}
99122

@@ -139,8 +162,7 @@ function setupNextTick() {
139162
args[i - 1] = arguments[i];
140163
}
141164

142-
nextTickQueue.push(new TickObject(callback, args,
143-
getDefaultTriggerAsyncId()));
165+
push(new TickObject(callback, args, getDefaultTriggerAsyncId()));
144166
}
145167

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

169191
if (triggerAsyncId === null)
170192
triggerAsyncId = getDefaultTriggerAsyncId();
171-
nextTickQueue.push(new TickObject(callback, args, triggerAsyncId));
193+
push(new TickObject(callback, args, triggerAsyncId));
172194
}
173195
}

lib/net.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -397,15 +397,6 @@ function writeAfterFIN(chunk, encoding, cb) {
397397
}
398398
}
399399

400-
Socket.prototype.read = function(n) {
401-
if (n === 0)
402-
return stream.Readable.prototype.read.call(this, n);
403-
404-
this.read = stream.Readable.prototype.read;
405-
this._consuming = true;
406-
return this.read(n);
407-
};
408-
409400
Socket.prototype.setTimeout = function(msecs, callback) {
410401
// Type checking identical to timers.enroll()
411402
msecs = validateTimerDuration(msecs);

0 commit comments

Comments
 (0)