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 f2d9379 as of 2018-03-04
This commit was automatically generated. For any problems, please contact jackhorton

Reviewed-By: Jack Horton <jahorto@microsoft.com>
  • Loading branch information
chakrabot committed Mar 6, 2018
2 parents 33d99e3 + f2d9379 commit 89fd183
Show file tree
Hide file tree
Showing 67 changed files with 764 additions and 536 deletions.
2 changes: 1 addition & 1 deletion benchmark/streams/pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const bench = common.createBenchmark(main, {
});

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

Expand Down
2 changes: 1 addition & 1 deletion benchmark/streams/readable-bigread.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const bench = common.createBenchmark(main, {
});

function main({ n }) {
const b = new Buffer(32);
const b = Buffer.alloc(32);
const s = new Readable();
function noop() {}
s._read = noop;
Expand Down
2 changes: 1 addition & 1 deletion benchmark/streams/readable-bigunevenread.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const bench = common.createBenchmark(main, {
});

function main({ n }) {
const b = new Buffer(32);
const b = Buffer.alloc(32);
const s = new Readable();
function noop() {}
s._read = noop;
Expand Down
2 changes: 1 addition & 1 deletion benchmark/streams/readable-readall.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const bench = common.createBenchmark(main, {
});

function main({ n }) {
const b = new Buffer(32);
const b = Buffer.alloc(32);
const s = new Readable();
function noop() {}
s._read = noop;
Expand Down
2 changes: 1 addition & 1 deletion benchmark/streams/readable-unevenread.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const bench = common.createBenchmark(main, {
});

function main({ n }) {
const b = new Buffer(32);
const b = Buffer.alloc(32);
const s = new Readable();
function noop() {}
s._read = noop;
Expand Down
3 changes: 3 additions & 0 deletions deps/openssl/openssl.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@
}, {
'defines': ['<@(openssl_default_defines_not_win)'],
'cflags': ['-Wno-missing-field-initializers'],
'xcode_settings': {
'WARNING_CFLAGS': ['-Wno-missing-field-initializers'],
},
'conditions': [
['OS=="mac"', {
'defines': ['<@(openssl_default_defines_mac)'],
Expand Down
9 changes: 9 additions & 0 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,14 @@ added: v7.7.0
A comma separated list of categories that should be traced when trace event
tracing is enabled using `--trace-events-enabled`.

### `--trace-event-file-pattern`
<!-- YAML
added: REPLACEME
-->

Template string specifying the filepath for the trace event data, it
supports `${rotation}` and `${pid}`.

### `--zero-fill-buffers`
<!-- YAML
added: v6.0.0
Expand Down Expand Up @@ -464,6 +472,7 @@ Node options that are allowed are:
- `--trace-deprecation`
- `--trace-events-categories`
- `--trace-events-enabled`
- `--trace-event-file-pattern`
- `--trace-sync-io`
- `--trace-warnings`
- `--track-heap-objects`
Expand Down
12 changes: 7 additions & 5 deletions doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3269,9 +3269,11 @@ napi_status napi_create_async_work(napi_env env,
- `[in] async_resource_name`: Identifier for the kind of resource that is
being provided for diagnostic information exposed by the `async_hooks` API.
- `[in] execute`: The native function which should be called to excute
the logic asynchronously.
the logic asynchronously. The given function is called from a worker pool
thread and can execute in parallel with the main event loop thread.
- `[in] complete`: The native function which will be called when the
asynchronous logic is comple or is cancelled.
asynchronous logic is completed or is cancelled. The given function is called
from the main event loop thread.
- `[in] data`: User-provided data context. This will be passed back into the
execute and complete functions.
- `[out] result`: `napi_async_work*` which is the handle to the newly created
Expand Down Expand Up @@ -3346,9 +3348,9 @@ callback invocation, even if it has been successfully cancelled.

## Custom Asynchronous Operations
The simple asynchronous work APIs above may not be appropriate for every
scenario, because with those the async execution still happens on the main
event loop. When using any other async mechanism, the following APIs are
necessary to ensure an async operation is properly tracked by the runtime.
scenario. When using any other asynchronous mechanism, the following APIs
are necessary to ensure an asynchronous operation is properly tracked by
the runtime.

### napi_async_init
<!-- YAML
Expand Down
9 changes: 9 additions & 0 deletions doc/api/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ Running Node.js with tracing enabled will produce log files that can be opened
in the [`chrome://tracing`](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool)
tab of Chrome.

The logging file is by default called `node_trace.${rotation}.log`, where
`${rotation}` is an incrementing log-rotation id. The filepath pattern can
be specified with `--trace-event-file-pattern` that accepts a template
string that supports `${rotation}` and `${pid}`. For example:

```txt
node --trace-events-enabled --trace-event-file-pattern '${pid}-${rotation}.log' server.js
```

Starting with Node 10.0.0, the tracing system uses the same time source as the
one used by `process.hrtime()` however the trace-event timestamps are expressed
in microseconds, unlike `process.hrtime()` which returns nanoseconds.
Expand Down
14 changes: 14 additions & 0 deletions doc/api/url.md
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,20 @@ changes:
The `url.format()` method returns a formatted URL string derived from
`urlObject`.

```js
url.format({
protocol: 'https',
hostname: 'example.com',
pathname: '/some/path',
query: {
page: 1,
format: 'json'
}
});

// => 'https://example.com/some/path?page=1&format=json'
```

If `urlObject` is not an object or a string, `url.format()` will throw a
[`TypeError`][].

Expand Down
4 changes: 4 additions & 0 deletions doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ Enable the collection of trace event tracing information.
A comma-separated list of categories that should be traced when trace event tracing is enabled using
.Fl -trace-events-enabled .
.
.It Fl -trace-event-file-pattern Ar pattern
Template string specifying the filepath for the trace event data, it
supports \fB${rotation}\fR and \fB${pid}\fR.
.
.It Fl -zero-fill-buffers
Automatically zero-fills all newly allocated Buffer and SlowBuffer instances.
.
Expand Down
11 changes: 5 additions & 6 deletions lib/_stream_duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ function Duplex(options) {
this.writable = false;

this.allowHalfOpen = true;
if (options && options.allowHalfOpen === false)
if (options && options.allowHalfOpen === false) {
this.allowHalfOpen = false;

this.once('end', onend);
this.once('end', onend);
}
}

Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
Expand Down Expand Up @@ -96,9 +96,8 @@ Object.defineProperty(Duplex.prototype, 'writableLength', {

// the no-half-open enforcer
function onend() {
// if we allow half-open state, or if the writable side ended,
// then we're ok.
if (this.allowHalfOpen || this._writableState.ended)
// If the writable side ended, then we're ok.
if (this._writableState.ended)
return;

// no more data can be written.
Expand Down
2 changes: 1 addition & 1 deletion lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ function resume_(stream, state) {

Readable.prototype.pause = function() {
debug('call pause flowing=%j', this._readableState.flowing);
if (false !== this._readableState.flowing) {
if (this._readableState.flowing !== false) {
debug('pause');
this._readableState.flowing = false;
this.emit('pause');
Expand Down
4 changes: 2 additions & 2 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,6 @@ function onConnectSecure() {
this.emit('secureConnect');
}

// Uncork incoming data
this.removeListener('end', onConnectEnd);
}

Expand All @@ -1083,7 +1082,8 @@ function onConnectEnd() {
if (!this._hadError) {
const options = this[kConnectOptions];
this._hadError = true;
const error = new Error('socket hang up');
const error = new Error('Client network socket disconnected before ' +
'secure TLS connection was established');
error.code = 'ECONNRESET';
error.path = options.path;
error.host = options.host;
Expand Down
2 changes: 1 addition & 1 deletion lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ Buffer.prototype.compare = function compare(target,
// - buffer - a Buffer to search
// - val - a string, Buffer, or number
// - byteOffset - an index into `buffer`; will be clamped to an int32
// - encoding - an optional encoding, relevant is val is a string
// - encoding - an optional encoding, relevant if val is a string
// - dir - true for indexOf, false for lastIndexOf
function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
if (typeof byteOffset === 'string') {
Expand Down
24 changes: 12 additions & 12 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ function isFd(path) {

fs.Stats = Stats;

function isFileType(fileType) {
// Use stats array directly to avoid creating an fs.Stats instance just for
// our internal use.
return (statValues[1/*mode*/] & S_IFMT) === fileType;
}

// Don't allow mode to accidentally be overwritten.
Object.defineProperties(fs, {
F_OK: { enumerable: true, value: constants.F_OK || 0 },
Expand Down Expand Up @@ -317,10 +323,8 @@ function readFileAfterStat(err) {
if (err)
return context.close(err);

// Use stats array directly to avoid creating an fs.Stats instance just for
// our internal use.
var size;
if ((statValues[1/*mode*/] & S_IFMT) === S_IFREG)
if (isFileType(S_IFREG))
size = context.size = statValues[8];
else
size = context.size = 0;
Expand Down Expand Up @@ -432,10 +436,8 @@ fs.readFileSync = function(path, options) {
var fd = isUserFd ? path : fs.openSync(path, options.flag || 'r', 0o666);

tryStatSync(fd, isUserFd);
// Use stats array directly to avoid creating an fs.Stats instance just for
// our internal use.
var size;
if ((statValues[1/*mode*/] & S_IFMT) === S_IFREG)
if (isFileType(S_IFREG))
size = statValues[8];
else
size = 0;
Expand Down Expand Up @@ -1604,8 +1606,7 @@ fs.realpathSync = function realpathSync(p, options) {

// continue if not a symlink, break if a pipe/socket
if (knownHard[base] || (cache && cache.get(base) === base)) {
if ((statValues[1/*mode*/] & S_IFMT) === S_IFIFO ||
(statValues[1/*mode*/] & S_IFMT) === S_IFSOCK) {
if (isFileType(S_IFIFO) || isFileType(S_IFSOCK)) {
break;
}
continue;
Expand All @@ -1624,7 +1625,7 @@ fs.realpathSync = function realpathSync(p, options) {
binding.lstat(baseLong, undefined, ctx);
handleErrorFromBinding(ctx);

if ((statValues[1/*mode*/] & S_IFMT) !== S_IFLNK) {
if (!isFileType(S_IFLNK)) {
knownHard[base] = true;
if (cache) cache.set(base, base);
continue;
Expand Down Expand Up @@ -1750,8 +1751,7 @@ fs.realpath = function realpath(p, options, callback) {

// continue if not a symlink, break if a pipe/socket
if (knownHard[base]) {
if ((statValues[1/*mode*/] & S_IFMT) === S_IFIFO ||
(statValues[1/*mode*/] & S_IFMT) === S_IFSOCK) {
if (isFileType(S_IFIFO) || isFileType(S_IFSOCK)) {
return callback(null, encodeRealpathResult(p, options));
}
return process.nextTick(LOOP);
Expand All @@ -1767,7 +1767,7 @@ fs.realpath = function realpath(p, options, callback) {
// our internal use.

// if not a symlink, skip to the next path part
if ((statValues[1/*mode*/] & S_IFMT) !== S_IFLNK) {
if (!isFileType(S_IFLNK)) {
knownHard[base] = true;
return process.nextTick(LOOP);
}
Expand Down
9 changes: 5 additions & 4 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const {
} = require('internal/timers');

const { ShutdownWrap, WriteWrap } = process.binding('stream_wrap');
const { constants } = binding;
const { constants, nameForErrorCode } = binding;

const NETServer = net.Server;
const TLSServer = tls.Server;
Expand Down Expand Up @@ -1769,6 +1769,8 @@ class Http2Stream extends Duplex {
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'code', 'number');
if (code < 0 || code > kMaxInt)
throw new errors.RangeError('ERR_OUT_OF_RANGE', 'code');
if (callback !== undefined && typeof callback !== 'function')
throw new errors.TypeError('ERR_INVALID_CALLBACK');

// Clear timeout and remove timeout listeners
this.setTimeout(0);
Expand All @@ -1786,8 +1788,6 @@ class Http2Stream extends Duplex {
state.rstCode = code;

if (callback !== undefined) {
if (typeof callback !== 'function')
throw new errors.TypeError('ERR_INVALID_CALLBACK');
this.once('close', callback);
}

Expand Down Expand Up @@ -1849,7 +1849,8 @@ class Http2Stream extends Duplex {
// abort and is already covered by aborted event, also allows more
// seamless compatibility with http1
if (err == null && code !== NGHTTP2_NO_ERROR && code !== NGHTTP2_CANCEL)
err = new errors.Error('ERR_HTTP2_STREAM_ERROR', code);
err = new errors.Error('ERR_HTTP2_STREAM_ERROR',
nameForErrorCode[code] || code);

this[kSession] = undefined;
this[kHandle] = undefined;
Expand Down
30 changes: 15 additions & 15 deletions lib/internal/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,33 +87,33 @@ if (process.binding('config').hasIntl) {
if (
code >= 0x1100 && (
code <= 0x115f || // Hangul Jamo
0x2329 === code || // LEFT-POINTING ANGLE BRACKET
0x232a === code || // RIGHT-POINTING ANGLE BRACKET
code === 0x2329 || // LEFT-POINTING ANGLE BRACKET
code === 0x232a || // RIGHT-POINTING ANGLE BRACKET
// CJK Radicals Supplement .. Enclosed CJK Letters and Months
(0x2e80 <= code && code <= 0x3247 && code !== 0x303f) ||
code >= 0x2e80 && code <= 0x3247 && code !== 0x303f ||
// Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
0x3250 <= code && code <= 0x4dbf ||
code >= 0x3250 && code <= 0x4dbf ||
// CJK Unified Ideographs .. Yi Radicals
0x4e00 <= code && code <= 0xa4c6 ||
code >= 0x4e00 && code <= 0xa4c6 ||
// Hangul Jamo Extended-A
0xa960 <= code && code <= 0xa97c ||
code >= 0xa960 && code <= 0xa97c ||
// Hangul Syllables
0xac00 <= code && code <= 0xd7a3 ||
code >= 0xac00 && code <= 0xd7a3 ||
// CJK Compatibility Ideographs
0xf900 <= code && code <= 0xfaff ||
code >= 0xf900 && code <= 0xfaff ||
// Vertical Forms
0xfe10 <= code && code <= 0xfe19 ||
code >= 0xfe10 && code <= 0xfe19 ||
// CJK Compatibility Forms .. Small Form Variants
0xfe30 <= code && code <= 0xfe6b ||
code >= 0xfe30 && code <= 0xfe6b ||
// Halfwidth and Fullwidth Forms
0xff01 <= code && code <= 0xff60 ||
0xffe0 <= code && code <= 0xffe6 ||
code >= 0xff01 && code <= 0xff60 ||
code >= 0xffe0 && code <= 0xffe6 ||
// Kana Supplement
0x1b000 <= code && code <= 0x1b001 ||
code >= 0x1b000 && code <= 0x1b001 ||
// Enclosed Ideographic Supplement
0x1f200 <= code && code <= 0x1f251 ||
code >= 0x1f200 && code <= 0x1f251 ||
// CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
0x20000 <= code && code <= 0x3fffd
code >= 0x20000 && code <= 0x3fffd
)
) {
return true;
Expand Down
6 changes: 2 additions & 4 deletions lib/internal/streams/legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ Stream.prototype.pipe = function(dest, options) {
var source = this;

function ondata(chunk) {
if (dest.writable) {
if (false === dest.write(chunk) && source.pause) {
source.pause();
}
if (dest.writable && dest.write(chunk) === false && source.pause) {
source.pause();
}
}

Expand Down
Loading

0 comments on commit 89fd183

Please sign in to comment.