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

Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
  • Loading branch information
chakrabot committed Mar 19, 2018
2 parents ca4423c + 3c61b87 commit 4afb088
Show file tree
Hide file tree
Showing 101 changed files with 2,208 additions and 1,445 deletions.
20 changes: 20 additions & 0 deletions benchmark/assert/ok.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

const common = require('../common.js');
const assert = require('assert');

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

function main({ n }) {
var i;
bench.start();
for (i = 0; i < n; ++i) {
if (i % 2 === 0)
assert(true);
else
assert(true, 'foo bar baz');
}
bench.end(n);
}
2 changes: 1 addition & 1 deletion benchmark/http2/respond-with-fd.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const fs = require('fs');
const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html');

const bench = common.createBenchmark(main, {
requests: [100, 1000, 10000, 100000, 1000000],
requests: [100, 1000, 10000, 100000],
streams: [100, 200, 1000],
clients: [1, 2],
benchmarker: ['h2load']
Expand Down
6 changes: 5 additions & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,18 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.4',
'v8_embedder_string': '-node.5',

# Enable disassembler for `--print-code` v8 options
'v8_enable_disassembler': 1,

# Don't bake anything extra into the snapshot.
'v8_use_external_startup_data%': 0,

# Disable V8 untrusted code mitigations.
# See https://github.com/v8/v8/wiki/Untrusted-code-mitigations
'v8_untrusted_code_mitigations': 'false',

# Some STL containers (e.g. std::vector) do not preserve ABI compatibility
# between debug and non-debug mode.
'disable_glibcxx_debug': 1,
Expand Down
6 changes: 6 additions & 0 deletions deps/v8/gypfiles/features.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@

# Controls the threshold for on-heap/off-heap Typed Arrays.
'v8_typed_array_max_size_in_heap%': 64,

# Enable mitigations for executing untrusted code.
'v8_untrusted_code_mitigations%': 'true',
},
'target_defaults': {
'conditions': [
Expand Down Expand Up @@ -143,6 +146,9 @@
['v8_enable_concurrent_marking==1', {
'defines': ['V8_CONCURRENT_MARKING',],
}],
['v8_untrusted_code_mitigations=="false"', {
'defines': ['DISABLE_UNTRUSTED_CODE_MITIGATIONS',],
}],
], # conditions
'configurations': {
'DebugBaseCommon': {
Expand Down
46 changes: 22 additions & 24 deletions doc/api/async_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ unintentional side effects.
Because printing to the console is an asynchronous operation, `console.log()`
will cause the AsyncHooks callbacks to be called. Using `console.log()` or
similar asynchronous operations inside an AsyncHooks callback function will thus
cause an infinite recursion. An easily solution to this when debugging is
to use a synchronous logging operation such as `fs.writeSync(1, msg)`. This
will print to stdout because `1` is the file descriptor for stdout and will
not invoke AsyncHooks recursively because it is synchronous.
cause an infinite recursion. An easy solution to this when debugging is to use a
synchronous logging operation such as `fs.writeSync(1, msg)`. This will print to
stdout because `1` is the file descriptor for stdout and will not invoke
AsyncHooks recursively because it is synchronous.

```js
const fs = require('fs');
Expand Down Expand Up @@ -246,9 +246,9 @@ instances and asynchronous work scheduled by them.

Users are able to define their own `type` when using the public embedder API.

*Note:* It is possible to have type name collisions. Embedders are encouraged
to use unique prefixes, such as the npm package name, to prevent collisions
when listening to the hooks.
It is possible to have type name collisions. Embedders are encouraged to use
unique prefixes, such as the npm package name, to prevent collisions when
listening to the hooks.

###### `triggerId`

Expand Down Expand Up @@ -282,10 +282,10 @@ TCPWRAP(4): trigger: 2 execution: 0
The `TCPSERVERWRAP` is the server which receives the connections.

The `TCPWRAP` is the new connection from the client. When a new
connection is made the `TCPWrap` instance is immediately constructed. This
happens outside of any JavaScript stack (side note: a `executionAsyncId()` of
`0` means it's being executed from C++, with no JavaScript stack above it).
With only that information, it would be impossible to link resources together in
connection is made, the `TCPWrap` instance is immediately constructed. This
happens outside of any JavaScript stack. (An `executionAsyncId()` of `0` means
that it is being executed from C++ with no JavaScript stack above it). With only
that information, it would be impossible to link resources together in
terms of what caused them to be created, so `triggerAsyncId` is given the task
of propagating what resource is responsible for the new resource's existence.

Expand Down Expand Up @@ -420,9 +420,9 @@ it only once.

Called immediately after the callback specified in `before` is completed.

*Note:* If an uncaught exception occurs during execution of the callback, then
`after` will run *after* the `'uncaughtException'` event is emitted or a
`domain`'s handler runs.
If an uncaught exception occurs during execution of the callback, then `after`
will run *after* the `'uncaughtException'` event is emitted or a `domain`'s
handler runs.


##### `destroy(asyncId)`
Expand All @@ -432,11 +432,10 @@ Called immediately after the callback specified in `before` is completed.
Called after the resource corresponding to `asyncId` is destroyed. It is also
called asynchronously from the embedder API `emitDestroy()`.

*Note:* Some resources depend on garbage collection for cleanup, so if a
reference is made to the `resource` object passed to `init` it is possible that
`destroy` will never be called, causing a memory leak in the application. If
the resource does not depend on garbage collection, then this will not be an
issue.
Some resources depend on garbage collection for cleanup, so if a reference is
made to the `resource` object passed to `init` it is possible that `destroy`
will never be called, causing a memory leak in the application. If the resource
does not depend on garbage collection, then this will not be an issue.

##### `promiseResolve(asyncId)`

Expand All @@ -447,9 +446,8 @@ invoked (either directly or through other means of resolving a promise).

Note that `resolve()` does not do any observable synchronous work.

*Note:* This does not necessarily mean that the `Promise` is fulfilled or
rejected at this point, if the `Promise` was resolved by assuming the state
of another `Promise`.
The `Promise` is not necessarily fulfilled or rejected at this point if the
`Promise` was resolved by assuming the state of another `Promise`.

```js
new Promise((resolve) => resolve(true)).then((a) => {});
Expand Down Expand Up @@ -587,8 +585,8 @@ like I/O, connection pooling, or managing callback queues may use the

### `class AsyncResource()`

The class `AsyncResource` was designed to be extended by the embedder's async
resources. Using this users can easily trigger the lifetime events of their
The class `AsyncResource` is designed to be extended by the embedder's async
resources. Using this, users can easily trigger the lifetime events of their
own resources.

The `init` hook will trigger when an `AsyncResource` is instantiated.
Expand Down
9 changes: 8 additions & 1 deletion doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,14 @@ client.
### ERR_HTTP2_SEND_FILE

An attempt was made to use the `Http2Stream.prototype.responseWithFile()` API to
send something other than a regular file.
send a directory.

<a id="ERR_HTTP2_SEND_FILE_NOSEEK"></a>
### ERR_HTTP2_SEND_FILE_NOSEEK

An attempt was made to use the `Http2Stream.prototype.responseWithFile()` API to
send something other than a regular file, but `offset` or `length` options were
provided.

<a id="ERR_HTTP2_SESSION_ERROR"></a>
### ERR_HTTP2_SESSION_ERROR
Expand Down
10 changes: 10 additions & 0 deletions doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,11 @@ if the `getTrailers` callback attempts to set such header fields.
#### http2stream.respondWithFD(fd[, headers[, options]])
<!-- YAML
added: v8.4.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/18936
description: Any readable file descriptor, not necessarily for a
regular file, is supported now.
-->

* `fd` {number} A readable file descriptor.
Expand Down Expand Up @@ -1313,6 +1318,11 @@ if the `getTrailers` callback attempts to set such header fields.
#### http2stream.respondWithFile(path[, headers[, options]])
<!-- YAML
added: v8.4.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/18936
description: Any readable file, not necessarily a
regular file, is supported now.
-->

* `path` {string|Buffer|URL}
Expand Down
2 changes: 1 addition & 1 deletion doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!--introduced_in=v7.10.0-->

> Stability: 1 - Experimental
> Stability: 2 - Stable

N-API (pronounced N as in the letter, followed by API)
is an API for building native Addons. It is independent from
Expand Down
15 changes: 13 additions & 2 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,8 @@ added: v0.9.4
* `destination` {stream.Writable} The destination for writing data
* `options` {Object} Pipe options
* `end` {boolean} End the writer when the reader ends. Defaults to `true`.
* Returns: {stream.Writable} making it possible to set up chains of piped
streams

The `readable.pipe()` method attaches a [Writable][] stream to the `readable`,
causing it to switch automatically into flowing mode and push all of its data
Expand Down Expand Up @@ -916,7 +918,9 @@ closed until the Node.js process exits, regardless of the specified options.
added: v9.3.0
-->

Return the value of `highWaterMark` passed when constructing this
* Returns: {number}

Returns the value of `highWaterMark` passed when constructing this
`Readable`.

##### readable.read([size])
Expand All @@ -925,7 +929,7 @@ added: v0.9.4
-->

* `size` {number} Optional argument to specify how much data to read.
* Return {string|Buffer|null}
* Returns: {string|Buffer|null}

The `readable.read()` method pulls some data out of the internal buffer and
returns it. If no data available to be read, `null` is returned. By default,
Expand Down Expand Up @@ -970,6 +974,8 @@ been emitted will return `null`. No runtime error will be raised.
added: v9.4.0
-->

* Returns: {number}

This property contains the number of bytes (or objects) in the queue
ready to be read. The value provides introspection data regarding
the status of the `highWaterMark`.
Expand Down Expand Up @@ -1034,6 +1040,7 @@ added: v0.9.4
-->

* `destination` {stream.Writable} Optional specific stream to unpipe
* Returns: {this}

The `readable.unpipe()` method detaches a Writable stream previously attached
using the [`stream.pipe()`][] method.
Expand Down Expand Up @@ -1135,6 +1142,7 @@ added: v0.9.4
-->

* `stream` {Stream} An "old style" readable stream
* Returns: {this}

Versions of Node.js prior to v0.10 had streams that did not implement the
entire `stream` module API as it is currently defined. (See [Compatibility][]
Expand Down Expand Up @@ -1165,6 +1173,9 @@ myReader.on('readable', () => {
added: v8.0.0
-->

* `error` {Error} Error which will be passed as payload in `'error'` event
* Returns: {this}

Destroy the stream, and emit `'error'` and `close`. After this call, the
readable stream will release any internal resources and subsequent calls
to `push` will be ignored.
Expand Down
9 changes: 3 additions & 6 deletions doc/onboarding-extras.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ to update from nodejs/node:
* `git remote update -p` OR `git fetch --all` (I prefer the former)
* `git merge --ff-only upstream/master` (or `REMOTENAME/BRANCH`)

## best practices
## Best practices

* commit often, out to your github fork (origin), open a PR
* when making PRs make sure to spend time on the description:
* every moment you spend writing a good description quarters the amount of
time it takes to understand your code.
* usually prefer to only squash at the *end* of your work, depends on the change
* When making PRs, spend time writing a thorough description.
* Usually only squash at the end of your work.
12 changes: 5 additions & 7 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const { openSync, closeSync, readSync } = require('fs');
const { parseExpressionAt } = require('internal/deps/acorn/dist/acorn');
const { inspect } = require('util');
const { EOL } = require('os');
const { NativeModule } = require('internal/bootstrap_loaders');
const { NativeModule } = require('internal/bootstrap/loaders');

// Escape control characters but not \n and \t to keep the line breaks and
// indentation intact.
Expand Down Expand Up @@ -210,13 +210,11 @@ function getErrMessage(call) {
}
}

function innerOk(args, fn) {
var [value, message] = args;

function innerOk(fn, argLen, value, message) {
if (!value) {
let generatedMessage = false;

if (args.length === 0) {
if (argLen === 0) {
generatedMessage = true;
message = 'No value argument passed to `assert.ok()`';
} else if (message == null && process.jsEngine !== 'chakracore') {
Expand Down Expand Up @@ -257,7 +255,7 @@ function innerOk(args, fn) {
// Pure assertion tests whether a value is truthy, as determined
// by !!value.
function ok(...args) {
innerOk(args, ok);
innerOk(ok, args.length, ...args);
}
assert.ok = ok;

Expand Down Expand Up @@ -567,7 +565,7 @@ assert.ifError = function ifError(err) {

// Expose a strict only variant of assert
function strict(...args) {
innerOk(args, strict);
innerOk(strict, args.length, ...args);
}
assert.strict = Object.assign(strict, assert, {
equal: assert.strictEqual,
Expand Down
2 changes: 1 addition & 1 deletion lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const {
// that test/parallel/test-buffer-bindingobj-no-zerofill.js is written.
let isAnyArrayBuffer;
try {
const { internalBinding } = require('internal/bootstrap_loaders');
const { internalBinding } = require('internal/bootstrap/loaders');
isAnyArrayBuffer = internalBinding('types').isAnyArrayBuffer;
} catch (e) {
isAnyArrayBuffer = require('util').types.isAnyArrayBuffer;
Expand Down
2 changes: 1 addition & 1 deletion lib/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const {
ERR_UNHANDLED_ERROR
} = require('internal/errors').codes;
const { createHook } = require('async_hooks');
const { internalBinding } = require('internal/bootstrap_loaders');
const { internalBinding } = require('internal/bootstrap/loaders');

// overwrite process.domain with a getter/setter that will allow for more
// effective optimizations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// This file creates the internal module & binding loaders used by built-in
// modules. In contrast, user land modules are loaded using
// lib/module.js (CommonJS Modules) or lib/internal/loader/* (ES Modules).
// lib/internal/modules/cjs/loader.js (CommonJS Modules) or
// lib/internal/modules/esm/* (ES Modules).
//
// This file is compiled and run by node.cc before bootstrap_node.js
// This file is compiled and run by node.cc before bootstrap/node.js
// was called, therefore the loaders are bootstraped before we start to
// actually bootstrap Node.js. It creates the following objects:
//
Expand All @@ -29,7 +30,7 @@
// so they can be loaded faster without the cost of I/O. This class makes the
// lib/internal/*, deps/internal/* modules and internalBinding() available by
// default to core modules, and lets the core modules require itself via
// require('internal/bootstrap_loaders') even when this file is not written in
// require('internal/bootstrap/loaders') even when this file is not written in
// CommonJS style.
//
// Other objects:
Expand Down Expand Up @@ -111,7 +112,7 @@
// Think of this as module.exports in this file even though it is not
// written in CommonJS style.
const loaderExports = { internalBinding, NativeModule };
const loaderId = 'internal/bootstrap_loaders';
const loaderId = 'internal/bootstrap/loaders';
NativeModule.require = function(id) {
if (id === loaderId) {
return loaderExports;
Expand Down Expand Up @@ -224,6 +225,6 @@
};

// This will be passed to the bootstrapNodeJSCore function in
// bootstrap_node.js.
// bootstrap/node.js.
return loaderExports;
});
Loading

0 comments on commit 4afb088

Please sign in to comment.