diff --git a/.eslintignore b/.eslintignore
index 27d1707084861f..6dca769b45ccf6 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,6 +1,7 @@
lib/internal/v8_prof_polyfill.js
lib/punycode.js
test/addons/??_*
+test/es-module/test-esm-dynamic-import.js
test/fixtures
test/message/esm_display_syntax_error.mjs
tools/node_modules
diff --git a/.eslintrc.yaml b/.eslintrc.yaml
index 0839e352cd399d..0e7e9ccfcb73b8 100644
--- a/.eslintrc.yaml
+++ b/.eslintrc.yaml
@@ -47,6 +47,7 @@ rules:
accessor-pairs: error
array-callback-return: error
dot-location: [error, property]
+ dot-notation: error
eqeqeq: [error, smart]
no-fallthrough: error
no-global-assign: error
@@ -74,6 +75,7 @@ rules:
message: __defineSetter__ is deprecated.
no-return-await: error
no-self-assign: error
+ no-self-compare: error
no-throw-literal: error
no-unused-labels: error
no-useless-call: error
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c6c8277ec86836..29bf5be559d75d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -29,7 +29,8 @@ release.
-9.5.0
+9.6.0
+9.5.0
9.4.0
9.3.0
9.2.1
diff --git a/COLLABORATOR_GUIDE.md b/COLLABORATOR_GUIDE.md
index 5a1d51dafe375c..95ef0653552c1e 100644
--- a/COLLABORATOR_GUIDE.md
+++ b/COLLABORATOR_GUIDE.md
@@ -368,7 +368,10 @@ Node.js uses three Deprecation levels:
being staged for deprecation in a future Node.js major release. An explicit
notice indicating the deprecated status is added to the API documentation
but no functional changes are implemented in the code. There will be no
- runtime deprecation warnings emitted for such deprecations.
+ runtime deprecation warnings emitted for such deprecations by default.
+ Documentation-only deprecations may trigger a runtime warning when launched
+ with [`--pending-deprecation`][] flag (or its alternative,
+ `NODE_PENDING_DEPRECATION=1` environment variable).
* *Runtime Deprecation* refers to the use of process warnings emitted at
runtime the first time that a deprecated API is used. A command-line
@@ -593,20 +596,20 @@ Validate that the commit message is properly formatted using
$ git rev-list upstream/master...HEAD | xargs core-validate-commit
```
+Optional: When landing your own commits, force push the amended commit to the
+branch you used to open the pull request. If your branch is called `bugfix`,
+then the command would be `git push --force-with-lease origin master:bugfix`.
+When the pull request is closed, this will cause the pull request to
+show the purple merged status rather than the red closed status that is
+usually used for pull requests that weren't merged.
+
Time to push it:
```text
$ git push upstream master
```
-* Optional: Force push the amended commit to the branch you used to
-open the pull request. If your branch is called `bugfix`, then the
-command would be `git push --force-with-lease origin master:bugfix`.
-When the pull request is closed, this will cause the pull request to
-show the purple merged status rather than the red closed status that is
-usually used for pull requests that weren't merged. Only do this when
-landing your own contributions.
-* Close the pull request with a "Landed in ``" comment. If
+Close the pull request with a "Landed in ``" comment. If
your pull request shows the purple merged status then you should still
add the "Landed in .." comment if you added
multiple commits.
@@ -744,6 +747,7 @@ LTS working group and the Release team.
[backporting guide]: doc/guides/backporting-to-release-lines.md
[Stability Index]: doc/api/documentation.md#stability-index
[Enhancement Proposal]: https://github.com/nodejs/node-eps
+[`--pending-deprecation`]: doc/api/cli.md#--pending-deprecation
[git-username]: https://help.github.com/articles/setting-your-username-in-git/
[`node-core-utils`]: https://github.com/nodejs/node-core-utils
[TSC]: https://github.com/nodejs/TSC
diff --git a/GOVERNANCE.md b/GOVERNANCE.md
index 4f1ff30d83411c..23c1ac8bb5106e 100644
--- a/GOVERNANCE.md
+++ b/GOVERNANCE.md
@@ -38,7 +38,7 @@ responsibility for the change. In the case of pull requests proposed
by an existing Collaborator, an additional Collaborator is required
for sign-off.
-If one or more Collaborators oppose a proposed change, then the change can not
+If one or more Collaborators oppose a proposed change, then the change cannot
be accepted unless:
* Discussions and/or additional changes result in no Collaborators objecting to
@@ -73,7 +73,7 @@ may request that the TSC restore them to active status.
## Technical Steering Committee
-A subset of the Collaborators form the Technical Steering Committee (TSC).
+A subset of the Collaborators forms the Technical Steering Committee (TSC).
The TSC has final authority over this project, including:
* Technical direction
diff --git a/Makefile b/Makefile
index eaebe4f2b55a4b..d7158eed378f97 100644
--- a/Makefile
+++ b/Makefile
@@ -616,7 +616,7 @@ doc-only: $(apidoc_dirs) $(apiassets) ## Builds the docs with the local or the
if [ ! -d doc/api/assets ]; then \
$(MAKE) tools/doc/node_modules/js-yaml/package.json; \
fi;
- @$(MAKE) -s $(apidocs_html) $(apidocs_json)
+ @$(MAKE) $(apidocs_html) $(apidocs_json)
.PHONY: doc
doc: $(NODE_EXE) doc-only
@@ -1183,6 +1183,7 @@ lint: ## Run JS, C++, MD and doc linters.
$(MAKE) lint-js || EXIT_STATUS=$$? ; \
$(MAKE) lint-cpp || EXIT_STATUS=$$? ; \
$(MAKE) lint-addon-docs || EXIT_STATUS=$$? ; \
+ $(MAKE) lint-md || EXIT_STATUS=$$? ; \
exit $$EXIT_STATUS
CONFLICT_RE=^>>>>>>> [0-9A-Fa-f]+|^<<<<<<< [A-Za-z]+
diff --git a/README.md b/README.md
index 47b8694797637b..687f0fb4723862 100644
--- a/README.md
+++ b/README.md
@@ -7,10 +7,9 @@
-Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js
-uses an event-driven, non-blocking I/O model that makes it lightweight and
-efficient. The Node.js package ecosystem, [npm][], is the largest ecosystem of
-open source libraries in the world.
+Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. For
+more information on using Node.js, see the
+[Node.js Website][].
The Node.js project is supported by the
[Node.js Foundation](https://nodejs.org/en/foundation/). Contributions,
@@ -245,8 +244,8 @@ For more information about the governance of the Node.js project, see
**Franziska Hinkelmann** <franziska.hinkelmann@gmail.com> (she/her)
* [Fishrock123](https://github.com/Fishrock123) -
**Jeremiah Senkpiel** <fishrock123@rocketmail.com>
-* [indutny](https://github.com/indutny) -
-**Fedor Indutny** <fedor.indutny@gmail.com>
+* [gibfahn](https://github.com/gibfahn) -
+**Gibson Fahnestock** <gibfahn@gmail.com> (he/him)
* [jasnell](https://github.com/jasnell) -
**James M Snell** <jasnell@gmail.com> (he/him)
* [joyeecheung](https://github.com/joyeecheung) -
@@ -255,8 +254,6 @@ For more information about the governance of the Node.js project, see
**Matteo Collina** <matteo.collina@gmail.com> (he/him)
* [mhdawson](https://github.com/mhdawson) -
**Michael Dawson** <michael_dawson@ca.ibm.com> (he/him)
-* [mscdex](https://github.com/mscdex) -
-**Brian White** <mscdex@mscdex.net>
* [MylesBorins](https://github.com/MylesBorins) -
**Myles Borins** <myles.borins@gmail.com> (he/him)
* [ofrobots](https://github.com/ofrobots) -
@@ -278,10 +275,14 @@ For more information about the governance of the Node.js project, see
**Ben Noordhuis** <info@bnoordhuis.nl>
* [chrisdickinson](https://github.com/chrisdickinson) -
**Chris Dickinson** <christopher.s.dickinson@gmail.com>
+* [indutny](https://github.com/indutny) -
+**Fedor Indutny** <fedor.indutny@gmail.com>
* [isaacs](https://github.com/isaacs) -
**Isaac Z. Schlueter** <i@izs.me>
* [joshgav](https://github.com/joshgav) -
**Josh Gavant** <josh.gavant@outlook.com>
+* [mscdex](https://github.com/mscdex) -
+**Brian White** <mscdex@mscdex.net>
* [nebrius](https://github.com/nebrius) -
**Bryan Hughes** <bryan@nebri.us>
* [orangemocha](https://github.com/orangemocha) -
@@ -339,6 +340,8 @@ For more information about the governance of the Node.js project, see
**Daniel Bevenius** <daniel.bevenius@gmail.com>
* [DavidCai1993](https://github.com/DavidCai1993) -
**David Cai** <davidcai1993@yahoo.com> (he/him)
+* [devsnek](https://github.com/devsnek) -
+**Gus Caplan** <me@gus.host> (he/him)
* [edsadr](https://github.com/edsadr) -
**Adrian Estrada** <edsadr@gmail.com> (he/him)
* [eljefedelrodeodeljefe](https://github.com/eljefedelrodeodeljefe) -
@@ -423,6 +426,8 @@ For more information about the governance of the Node.js project, see
**Mikeal Rogers** <mikeal.rogers@gmail.com>
* [misterdjules](https://github.com/misterdjules) -
**Julien Gilli** <jgilli@nodejs.org>
+* [mmarchini](https://github.com/mmarchini) -
+**Matheus Marchini** <matheus@sthima.com>
* [mscdex](https://github.com/mscdex) -
**Brian White** <mscdex@mscdex.net>
* [MylesBorins](https://github.com/MylesBorins) -
@@ -509,6 +514,8 @@ For more information about the governance of the Node.js project, see
**Jeremy Whitlock** <jwhitlock@apache.org>
* [XadillaX](https://github.com/XadillaX) -
**Khaidi Chu** <i@2333.moe> (he/him)
+* [yhwang](https://github.com/yhwang) -
+**Yihong Wang** <yh.wang@ibm.com>
* [yorkie](https://github.com/yorkie) -
**Yorkie Liu** <yorkiefixer@gmail.com>
* [yosuke-furukawa](https://github.com/yosuke-furukawa) -
@@ -590,12 +597,13 @@ Previous releases may also have been signed with one of the following GPG keys:
* [Contributing to the project][]
* [Working Groups][]
+* [Strategic Initiatives][]
-[npm]: https://www.npmjs.com
[Code of Conduct]: https://github.com/nodejs/admin/blob/master/CODE_OF_CONDUCT.md
[Contributing to the project]: CONTRIBUTING.md
[Node.js Help]: https://github.com/nodejs/help
[Node.js Website]: https://nodejs.org/en/
[Questions tagged 'node.js' on StackOverflow]: https://stackoverflow.com/questions/tagged/node.js
[Working Groups]: https://github.com/nodejs/TSC/blob/master/WORKING_GROUPS.md
+[Strategic Initiatives]: https://github.com/nodejs/TSC/blob/master/Strategic-Initiatives.md
[#node.js channel on chat.freenode.net]: https://webchat.freenode.net?channels=node.js&uio=d4
diff --git a/benchmark/_http-benchmarkers.js b/benchmark/_http-benchmarkers.js
index 55ebcc96ba21ed..76e02504b27ec1 100644
--- a/benchmark/_http-benchmarkers.js
+++ b/benchmark/_http-benchmarkers.js
@@ -185,7 +185,7 @@ exports.run = function(options, callback) {
port: exports.PORT,
path: '/',
connections: 100,
- duration: 10,
+ duration: 5,
benchmarker: exports.default_http_benchmarker
}, options);
if (!options.benchmarker) {
diff --git a/benchmark/assert/deepequal-buffer.js b/benchmark/assert/deepequal-buffer.js
index 0e7494544d3387..9556a81ec3b151 100644
--- a/benchmark/assert/deepequal-buffer.js
+++ b/benchmark/assert/deepequal-buffer.js
@@ -14,8 +14,6 @@ const bench = common.createBenchmark(main, {
});
function main({ len, n, method }) {
- var i;
-
const data = Buffer.allocUnsafe(len + 1);
const actual = Buffer.alloc(len);
const expected = Buffer.alloc(len);
@@ -24,40 +22,13 @@ function main({ len, n, method }) {
data.copy(expected);
data.copy(expectedWrong);
- switch (method) {
- case '':
- // Empty string falls through to next line as default, mostly for tests.
- case 'deepEqual':
- bench.start();
- for (i = 0; i < n; ++i) {
- // eslint-disable-next-line no-restricted-properties
- assert.deepEqual(actual, expected);
- }
- bench.end(n);
- break;
- case 'deepStrictEqual':
- bench.start();
- for (i = 0; i < n; ++i) {
- assert.deepStrictEqual(actual, expected);
- }
- bench.end(n);
- break;
- case 'notDeepEqual':
- bench.start();
- for (i = 0; i < n; ++i) {
- // eslint-disable-next-line no-restricted-properties
- assert.notDeepEqual(actual, expectedWrong);
- }
- bench.end(n);
- break;
- case 'notDeepStrictEqual':
- bench.start();
- for (i = 0; i < n; ++i) {
- assert.notDeepStrictEqual(actual, expectedWrong);
- }
- bench.end(n);
- break;
- default:
- throw new Error('Unsupported method');
+ // eslint-disable-next-line no-restricted-properties
+ const fn = method !== '' ? assert[method] : assert.deepEqual;
+ const value2 = method.includes('not') ? expectedWrong : expected;
+
+ bench.start();
+ for (var i = 0; i < n; ++i) {
+ fn(actual, value2);
}
+ bench.end(n);
}
diff --git a/benchmark/assert/deepequal-map.js b/benchmark/assert/deepequal-map.js
index 085274e8bfb943..bdd3c5c6b8c514 100644
--- a/benchmark/assert/deepequal-map.js
+++ b/benchmark/assert/deepequal-map.js
@@ -117,6 +117,6 @@ function main({ n, len, method }) {
benchmark(assert.notDeepEqual, n, values, values2);
break;
default:
- throw new Error('Unsupported method');
+ throw new Error(`Unsupported method ${method}`);
}
}
diff --git a/benchmark/assert/deepequal-object.js b/benchmark/assert/deepequal-object.js
index 2c2549d58485fc..4c95006b3b8bc7 100644
--- a/benchmark/assert/deepequal-object.js
+++ b/benchmark/assert/deepequal-object.js
@@ -28,47 +28,19 @@ function createObj(source, add = '') {
function main({ size, n, method }) {
// TODO: Fix this "hack". `n` should not be manipulated.
n = n / size;
- var i;
const source = Array.apply(null, Array(size));
const actual = createObj(source);
const expected = createObj(source);
const expectedWrong = createObj(source, '4');
- switch (method) {
- case '':
- // Empty string falls through to next line as default, mostly for tests.
- case 'deepEqual':
- bench.start();
- for (i = 0; i < n; ++i) {
- // eslint-disable-next-line no-restricted-properties
- assert.deepEqual(actual, expected);
- }
- bench.end(n);
- break;
- case 'deepStrictEqual':
- bench.start();
- for (i = 0; i < n; ++i) {
- assert.deepStrictEqual(actual, expected);
- }
- bench.end(n);
- break;
- case 'notDeepEqual':
- bench.start();
- for (i = 0; i < n; ++i) {
- // eslint-disable-next-line no-restricted-properties
- assert.notDeepEqual(actual, expectedWrong);
- }
- bench.end(n);
- break;
- case 'notDeepStrictEqual':
- bench.start();
- for (i = 0; i < n; ++i) {
- assert.notDeepStrictEqual(actual, expectedWrong);
- }
- bench.end(n);
- break;
- default:
- throw new Error('Unsupported method');
+ // eslint-disable-next-line no-restricted-properties
+ const fn = method !== '' ? assert[method] : assert.deepEqual;
+ const value2 = method.includes('not') ? expectedWrong : expected;
+
+ bench.start();
+ for (var i = 0; i < n; ++i) {
+ fn(actual, value2);
}
+ bench.end(n);
}
diff --git a/benchmark/assert/deepequal-prims-and-objs-big-array-set.js b/benchmark/assert/deepequal-prims-and-objs-big-array-set.js
index 04802a76928cb2..90dbf1059361a5 100644
--- a/benchmark/assert/deepequal-prims-and-objs-big-array-set.js
+++ b/benchmark/assert/deepequal-prims-and-objs-big-array-set.js
@@ -30,12 +30,19 @@ const bench = common.createBenchmark(main, {
]
});
+function run(fn, n, actual, expected) {
+ bench.start();
+ for (var i = 0; i < n; ++i) {
+ fn(actual, expected);
+ }
+ bench.end(n);
+}
+
function main({ n, len, primitive, method }) {
const prim = primValues[primitive];
const actual = [];
const expected = [];
const expectedWrong = [];
- var i;
for (var x = 0; x < len; x++) {
actual.push(prim);
@@ -51,69 +58,37 @@ function main({ n, len, primitive, method }) {
const expectedWrongSet = new Set(expectedWrong);
switch (method) {
+ // Empty string falls through to next line as default, mostly for tests.
case '':
- // Empty string falls through to next line as default, mostly for tests.
case 'deepEqual_Array':
- bench.start();
- for (i = 0; i < n; ++i) {
- // eslint-disable-next-line no-restricted-properties
- assert.deepEqual(actual, expected);
- }
- bench.end(n);
+ // eslint-disable-next-line no-restricted-properties
+ run(assert.deepEqual, n, actual, expected);
break;
case 'deepStrictEqual_Array':
- bench.start();
- for (i = 0; i < n; ++i) {
- assert.deepStrictEqual(actual, expected);
- }
- bench.end(n);
+ run(assert.deepStrictEqual, n, actual, expected);
break;
case 'notDeepEqual_Array':
- bench.start();
- for (i = 0; i < n; ++i) {
- // eslint-disable-next-line no-restricted-properties
- assert.notDeepEqual(actual, expectedWrong);
- }
- bench.end(n);
+ // eslint-disable-next-line no-restricted-properties
+ run(assert.notDeepEqual, n, actual, expectedWrong);
break;
case 'notDeepStrictEqual_Array':
- bench.start();
- for (i = 0; i < n; ++i) {
- assert.notDeepStrictEqual(actual, expectedWrong);
- }
- bench.end(n);
+ run(assert.notDeepStrictEqual, n, actual, expectedWrong);
break;
case 'deepEqual_Set':
- bench.start();
- for (i = 0; i < n; ++i) {
- // eslint-disable-next-line no-restricted-properties
- assert.deepEqual(actualSet, expectedSet);
- }
- bench.end(n);
+ // eslint-disable-next-line no-restricted-properties
+ run(assert.deepEqual, n, actualSet, expectedSet);
break;
case 'deepStrictEqual_Set':
- bench.start();
- for (i = 0; i < n; ++i) {
- assert.deepStrictEqual(actualSet, expectedSet);
- }
- bench.end(n);
+ run(assert.deepStrictEqual, n, actualSet, expectedSet);
break;
case 'notDeepEqual_Set':
- bench.start();
- for (i = 0; i < n; ++i) {
- // eslint-disable-next-line no-restricted-properties
- assert.notDeepEqual(actualSet, expectedWrongSet);
- }
- bench.end(n);
+ // eslint-disable-next-line no-restricted-properties
+ run(assert.notDeepEqual, n, actualSet, expectedWrongSet);
break;
case 'notDeepStrictEqual_Set':
- bench.start();
- for (i = 0; i < n; ++i) {
- assert.notDeepStrictEqual(actualSet, expectedWrongSet);
- }
- bench.end(n);
+ run(assert.notDeepStrictEqual, n, actualSet, expectedWrongSet);
break;
default:
- throw new Error('Unsupported method');
+ throw new Error(`Unsupported method "${method}"`);
}
}
diff --git a/benchmark/assert/deepequal-prims-and-objs-big-loop.js b/benchmark/assert/deepequal-prims-and-objs-big-loop.js
index 09797dfaf2df21..ec51201d51839d 100644
--- a/benchmark/assert/deepequal-prims-and-objs-big-loop.js
+++ b/benchmark/assert/deepequal-prims-and-objs-big-loop.js
@@ -29,43 +29,14 @@ function main({ n, primitive, method }) {
const actual = prim;
const expected = prim;
const expectedWrong = 'b';
- var i;
- // Creates new array to avoid loop invariant code motion
- switch (method) {
- case '':
- // Empty string falls through to next line as default, mostly for tests.
- case 'deepEqual':
- bench.start();
- for (i = 0; i < n; ++i) {
- // eslint-disable-next-line no-restricted-properties
- assert.deepEqual([actual], [expected]);
- }
- bench.end(n);
- break;
- case 'deepStrictEqual':
- bench.start();
- for (i = 0; i < n; ++i) {
- assert.deepStrictEqual([actual], [expected]);
- }
- bench.end(n);
- break;
- case 'notDeepEqual':
- bench.start();
- for (i = 0; i < n; ++i) {
- // eslint-disable-next-line no-restricted-properties
- assert.notDeepEqual([actual], [expectedWrong]);
- }
- bench.end(n);
- break;
- case 'notDeepStrictEqual':
- bench.start();
- for (i = 0; i < n; ++i) {
- assert.notDeepStrictEqual([actual], [expectedWrong]);
- }
- bench.end(n);
- break;
- default:
- throw new Error('Unsupported method');
+ // eslint-disable-next-line no-restricted-properties
+ const fn = method !== '' ? assert[method] : assert.deepEqual;
+ const value2 = method.includes('not') ? expectedWrong : expected;
+
+ bench.start();
+ for (var i = 0; i < n; ++i) {
+ fn([actual], [value2]);
}
+ bench.end(n);
}
diff --git a/benchmark/assert/deepequal-set.js b/benchmark/assert/deepequal-set.js
index ebcf33cc6d5254..e70ddf10e93626 100644
--- a/benchmark/assert/deepequal-set.js
+++ b/benchmark/assert/deepequal-set.js
@@ -126,6 +126,6 @@ function main({ n, len, method }) {
benchmark(assert.notDeepEqual, n, values, values2);
break;
default:
- throw new Error('Unsupported method');
+ throw new Error(`Unsupported method "${method}"`);
}
}
diff --git a/benchmark/assert/deepequal-typedarrays.js b/benchmark/assert/deepequal-typedarrays.js
index 01546801ff3004..50e6e525b20a0c 100644
--- a/benchmark/assert/deepequal-typedarrays.js
+++ b/benchmark/assert/deepequal-typedarrays.js
@@ -31,42 +31,14 @@ function main({ type, n, len, method }) {
const expectedWrong = Buffer.alloc(len);
const wrongIndex = Math.floor(len / 2);
expectedWrong[wrongIndex] = 123;
- var i;
- switch (method) {
- case '':
- // Empty string falls through to next line as default, mostly for tests.
- case 'deepEqual':
- bench.start();
- for (i = 0; i < n; ++i) {
- // eslint-disable-next-line no-restricted-properties
- assert.deepEqual(actual, expected);
- }
- bench.end(n);
- break;
- case 'deepStrictEqual':
- bench.start();
- for (i = 0; i < n; ++i) {
- assert.deepStrictEqual(actual, expected);
- }
- bench.end(n);
- break;
- case 'notDeepEqual':
- bench.start();
- for (i = 0; i < n; ++i) {
- // eslint-disable-next-line no-restricted-properties
- assert.notDeepEqual(actual, expectedWrong);
- }
- bench.end(n);
- break;
- case 'notDeepStrictEqual':
- bench.start();
- for (i = 0; i < n; ++i) {
- assert.notDeepStrictEqual(actual, expectedWrong);
- }
- bench.end(n);
- break;
- default:
- throw new Error('Unsupported method');
+ // eslint-disable-next-line no-restricted-properties
+ const fn = method !== '' ? assert[method] : assert.deepEqual;
+ const value2 = method.includes('not') ? expectedWrong : expected;
+
+ bench.start();
+ for (var i = 0; i < n; ++i) {
+ fn(actual, value2);
}
+ bench.end(n);
}
diff --git a/benchmark/async_hooks/gc-tracking.js b/benchmark/async_hooks/gc-tracking.js
index a569fb8fa92485..d74b2bac463e28 100644
--- a/benchmark/async_hooks/gc-tracking.js
+++ b/benchmark/async_hooks/gc-tracking.js
@@ -22,22 +22,23 @@ function endAfterGC(n) {
}
function main({ n, method }) {
+ var i;
switch (method) {
case 'trackingEnabled':
bench.start();
- for (let i = 0; i < n; i++) {
+ for (i = 0; i < n; i++) {
new AsyncResource('foobar');
}
endAfterGC(n);
break;
case 'trackingDisabled':
bench.start();
- for (let i = 0; i < n; i++) {
+ for (i = 0; i < n; i++) {
new AsyncResource('foobar', { requireManualDestroy: true });
}
endAfterGC(n);
break;
default:
- throw new Error('Unsupported method');
+ throw new Error(`Unsupported method "${method}"`);
}
}
diff --git a/benchmark/buffers/buffer-bytelength.js b/benchmark/buffers/buffer-bytelength.js
index 0617b4feb3f140..fa8852a233ea88 100644
--- a/benchmark/buffers/buffer-bytelength.js
+++ b/benchmark/buffers/buffer-bytelength.js
@@ -17,10 +17,9 @@ const chars = [
function main({ n, len, encoding }) {
var strings = [];
- var results;
+ var results = [ len * 16 ];
if (encoding === 'buffer') {
strings = [ Buffer.alloc(len * 16, 'a') ];
- results = [ len * 16 ];
} else {
for (const string of chars) {
// Strings must be built differently, depending on encoding
diff --git a/benchmark/buffers/buffer-compare-offset.js b/benchmark/buffers/buffer-compare-offset.js
index 850fe11d3f429e..551fcd2f0cec37 100644
--- a/benchmark/buffers/buffer-compare-offset.js
+++ b/benchmark/buffers/buffer-compare-offset.js
@@ -8,26 +8,22 @@ const bench = common.createBenchmark(main, {
});
function compareUsingSlice(b0, b1, len, iter) {
- var i;
- bench.start();
- for (i = 0; i < iter; i++)
+ for (var i = 0; i < iter; i++)
Buffer.compare(b0.slice(1, len), b1.slice(1, len));
- bench.end(iter / 1e6);
}
function compareUsingOffset(b0, b1, len, iter) {
- var i;
- bench.start();
- for (i = 0; i < iter; i++)
+ for (var i = 0; i < iter; i++)
b0.compare(b1, 1, len, 1, len);
- bench.end(iter / 1e6);
}
function main({ millions, size, method }) {
const iter = millions * 1e6;
const fn = method === 'slice' ? compareUsingSlice : compareUsingOffset;
+ bench.start();
fn(Buffer.alloc(size, 'a'),
Buffer.alloc(size, 'b'),
size >> 1,
iter);
+ bench.end(millions);
}
diff --git a/benchmark/buffers/buffer-creation.js b/benchmark/buffers/buffer-creation.js
index 73e620955e91db..a7b340131eb8aa 100644
--- a/benchmark/buffers/buffer-creation.js
+++ b/benchmark/buffers/buffer-creation.js
@@ -16,51 +16,38 @@ const bench = common.createBenchmark(main, {
});
function main({ len, n, type }) {
+ let fn, i;
switch (type) {
case '':
case 'fast-alloc':
- bench.start();
- for (let i = 0; i < n * 1024; i++) {
- Buffer.alloc(len);
- }
- bench.end(n);
+ fn = Buffer.alloc;
break;
case 'fast-alloc-fill':
bench.start();
- for (let i = 0; i < n * 1024; i++) {
+ for (i = 0; i < n * 1024; i++) {
Buffer.alloc(len, 0);
}
bench.end(n);
- break;
+ return;
case 'fast-allocUnsafe':
- bench.start();
- for (let i = 0; i < n * 1024; i++) {
- Buffer.allocUnsafe(len);
- }
- bench.end(n);
+ fn = Buffer.allocUnsafe;
break;
case 'slow-allocUnsafe':
- bench.start();
- for (let i = 0; i < n * 1024; i++) {
- Buffer.allocUnsafeSlow(len);
- }
- bench.end(n);
+ fn = Buffer.allocUnsafeSlow;
break;
case 'slow':
- bench.start();
- for (let i = 0; i < n * 1024; i++) {
- SlowBuffer(len);
- }
- bench.end(n);
+ fn = SlowBuffer;
break;
case 'buffer()':
- bench.start();
- for (let i = 0; i < n * 1024; i++) {
- Buffer(len);
- }
- bench.end(n);
+ fn = Buffer;
break;
default:
- assert.fail(null, null, 'Should not get here');
+ assert.fail('Should not get here');
+ }
+
+ bench.start();
+ for (i = 0; i < n * 1024; i++) {
+ fn(len);
}
+ bench.end(n);
}
diff --git a/benchmark/buffers/buffer-hex.js b/benchmark/buffers/buffer-hex.js
index 1bdef81139ffe7..4d87313961aa67 100644
--- a/benchmark/buffers/buffer-hex.js
+++ b/benchmark/buffers/buffer-hex.js
@@ -9,15 +9,16 @@ const bench = common.createBenchmark(main, {
function main({ len, n }) {
const buf = Buffer.alloc(len);
+ var i;
- for (let i = 0; i < buf.length; i++)
+ for (i = 0; i < buf.length; i++)
buf[i] = i & 0xff;
const hex = buf.toString('hex');
bench.start();
- for (let i = 0; i < n; i += 1)
+ for (i = 0; i < n; i += 1)
Buffer.from(hex, 'hex');
bench.end(n);
diff --git a/benchmark/buffers/buffer-iterate.js b/benchmark/buffers/buffer-iterate.js
index 8531e1cae82115..7a275b0bcb8182 100644
--- a/benchmark/buffers/buffer-iterate.js
+++ b/benchmark/buffers/buffer-iterate.js
@@ -20,36 +20,30 @@ function main({ size, type, method, n }) {
const clazz = type === 'fast' ? Buffer : SlowBuffer;
const buffer = new clazz(size);
buffer.fill(0);
- methods[method || 'for'](buffer, n);
-}
-
+ const fn = methods[method || 'for'];
-function benchFor(buffer, n) {
bench.start();
+ fn(buffer, n);
+ bench.end(n);
+}
+function benchFor(buffer, n) {
for (var k = 0; k < n; k++) {
for (var i = 0; i < buffer.length; i++) {
assert(buffer[i] === 0);
}
}
-
- bench.end(n);
}
function benchForOf(buffer, n) {
- bench.start();
-
for (var k = 0; k < n; k++) {
for (const b of buffer) {
assert(b === 0);
}
}
- bench.end(n);
}
function benchIterator(buffer, n) {
- bench.start();
-
for (var k = 0; k < n; k++) {
const iter = buffer[Symbol.iterator]();
var cur = iter.next();
@@ -60,6 +54,4 @@ function benchIterator(buffer, n) {
}
}
-
- bench.end(n);
}
diff --git a/benchmark/buffers/buffer-read-float.js b/benchmark/buffers/buffer-read-float.js
index 5dda2486c6711a..afd9edf5578308 100644
--- a/benchmark/buffers/buffer-read-float.js
+++ b/benchmark/buffers/buffer-read-float.js
@@ -9,12 +9,10 @@ const bench = common.createBenchmark(main, {
millions: [1]
});
-function main(conf) {
- const noAssert = conf.noAssert === 'true';
- const len = +conf.millions * 1e6;
+function main({ noAssert, millions, type, endian, value }) {
+ noAssert = noAssert === 'true';
+ type = type || 'Double';
const buff = Buffer.alloc(8);
- const type = conf.type || 'Double';
- const endian = conf.endian;
const fn = `read${type}${endian}`;
const values = {
Double: {
@@ -32,15 +30,12 @@ function main(conf) {
nan: NaN,
},
};
- const value = values[type][conf.value];
- buff[`write${type}${endian}`](value, 0, noAssert);
- const testFunction = new Function('buff', `
- for (var i = 0; i !== ${len}; i++) {
- buff.${fn}(0, ${JSON.stringify(noAssert)});
- }
- `);
+ buff[`write${type}${endian}`](values[type][value], 0, noAssert);
+
bench.start();
- testFunction(buff);
- bench.end(len / 1e6);
+ for (var i = 0; i !== millions * 1e6; i++) {
+ buff[fn](0, noAssert);
+ }
+ bench.end(millions);
}
diff --git a/benchmark/buffers/buffer-read.js b/benchmark/buffers/buffer-read.js
index 41e842f3123623..868f5cede8bd2d 100644
--- a/benchmark/buffers/buffer-read.js
+++ b/benchmark/buffers/buffer-read.js
@@ -27,18 +27,14 @@ const bench = common.createBenchmark(main, {
function main({ noAssert, millions, buf, type }) {
noAssert = noAssert === 'true';
- const len = millions * 1e6;
const clazz = buf === 'fast' ? Buffer : require('buffer').SlowBuffer;
const buff = new clazz(8);
const fn = `read${type || 'UInt8'}`;
buff.writeDoubleLE(0, 0, noAssert);
- const testFunction = new Function('buff', `
- for (var i = 0; i !== ${len}; i++) {
- buff.${fn}(0, ${JSON.stringify(noAssert)});
- }
- `);
bench.start();
- testFunction(buff);
- bench.end(len / 1e6);
+ for (var i = 0; i !== millions * 1e6; i++) {
+ buff[fn](0, noAssert);
+ }
+ bench.end(millions);
}
diff --git a/benchmark/buffers/buffer-write.js b/benchmark/buffers/buffer-write.js
index ce2fbe3103cb83..823e95bf15d704 100644
--- a/benchmark/buffers/buffer-write.js
+++ b/benchmark/buffers/buffer-write.js
@@ -46,36 +46,29 @@ const mod = {
};
function main({ noAssert, millions, buf, type }) {
- const len = millions * 1e6;
const clazz = buf === 'fast' ? Buffer : require('buffer').SlowBuffer;
const buff = new clazz(8);
const fn = `write${type || 'UInt8'}`;
if (/Int/.test(fn))
- benchInt(buff, fn, len, noAssert);
+ benchInt(buff, fn, millions, noAssert);
else
- benchFloat(buff, fn, len, noAssert);
+ benchFloat(buff, fn, millions, noAssert);
}
-function benchInt(buff, fn, len, noAssert) {
+function benchInt(buff, fn, millions, noAssert) {
const m = mod[fn];
- const testFunction = new Function('buff', `
- for (var i = 0; i !== ${len}; i++) {
- buff.${fn}(i & ${m}, 0, ${noAssert});
- }
- `);
bench.start();
- testFunction(buff);
- bench.end(len / 1e6);
+ for (var i = 0; i !== millions * 1e6; i++) {
+ buff[fn](i & m, 0, noAssert);
+ }
+ bench.end(millions);
}
-function benchFloat(buff, fn, len, noAssert) {
- const testFunction = new Function('buff', `
- for (var i = 0; i !== ${len}; i++) {
- buff.${fn}(i, 0, ${noAssert});
- }
- `);
+function benchFloat(buff, fn, millions, noAssert) {
bench.start();
- testFunction(buff);
- bench.end(len / 1e6);
+ for (var i = 0; i !== millions * 1e6; i++) {
+ buff[fn](i, 0, noAssert);
+ }
+ bench.end(millions);
}
diff --git a/benchmark/buffers/buffer_zero.js b/benchmark/buffers/buffer_zero.js
index 06b68c313f1241..1263732dce8e43 100644
--- a/benchmark/buffers/buffer_zero.js
+++ b/benchmark/buffers/buffer_zero.js
@@ -11,12 +11,9 @@ const zeroBuffer = Buffer.alloc(0);
const zeroString = '';
function main({ n, type }) {
- bench.start();
-
- if (type === 'buffer')
- for (let i = 0; i < n * 1024; i++) Buffer.from(zeroBuffer);
- else if (type === 'string')
- for (let i = 0; i < n * 1024; i++) Buffer.from(zeroString);
+ const data = type === 'buffer' ? zeroBuffer : zeroString;
+ bench.start();
+ for (var i = 0; i < n * 1024; i++) Buffer.from(data);
bench.end(n);
}
diff --git a/benchmark/compare.js b/benchmark/compare.js
index 6b51a70eb9a41b..e7866b60e36418 100644
--- a/benchmark/compare.js
+++ b/benchmark/compare.js
@@ -1,6 +1,7 @@
'use strict';
-const fork = require('child_process').fork;
+const { fork } = require('child_process');
+const { inspect } = require('util');
const path = require('path');
const CLI = require('./_cli.js');
const BenchmarkProgress = require('./_benchmark_progress.js');
@@ -76,7 +77,7 @@ if (showProgress) {
// Construct configuration string, " A=a, B=b, ..."
let conf = '';
for (const key of Object.keys(data.conf)) {
- conf += ` ${key}=${JSON.stringify(data.conf[key])}`;
+ conf += ` ${key}=${inspect(data.conf[key])}`;
}
conf = conf.slice(1);
// Escape quotes (") for correct csv formatting
diff --git a/benchmark/crypto/aes-gcm-throughput.js b/benchmark/crypto/aes-gcm-throughput.js
index 246455de78ad88..5c1e71e7280575 100644
--- a/benchmark/crypto/aes-gcm-throughput.js
+++ b/benchmark/crypto/aes-gcm-throughput.js
@@ -8,13 +8,13 @@ const bench = common.createBenchmark(main, {
len: [1024, 4 * 1024, 16 * 1024, 64 * 1024, 256 * 1024, 1024 * 1024]
});
-function main(conf) {
- const message = Buffer.alloc(conf.len, 'b');
- const key = crypto.randomBytes(keylen[conf.cipher]);
+function main({ n, len, cipher }) {
+ const message = Buffer.alloc(len, 'b');
+ const key = crypto.randomBytes(keylen[cipher]);
const iv = crypto.randomBytes(12);
const associate_data = Buffer.alloc(16, 'z');
bench.start();
- AEAD_Bench(conf.cipher, message, associate_data, key, iv, conf.n, conf.len);
+ AEAD_Bench(cipher, message, associate_data, key, iv, n, len);
}
function AEAD_Bench(cipher, message, associate_data, key, iv, n, len) {
diff --git a/benchmark/crypto/cipher-stream.js b/benchmark/crypto/cipher-stream.js
index ca36bd736d9aea..64f6ff7b7292be 100644
--- a/benchmark/crypto/cipher-stream.js
+++ b/benchmark/crypto/cipher-stream.js
@@ -9,8 +9,7 @@ const bench = common.createBenchmark(main, {
api: ['legacy', 'stream']
});
-function main(conf) {
- var api = conf.api;
+function main({ api, cipher, type, len, writes }) {
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
console.error('Crypto streams not available until v0.10');
// use the legacy, just so that we can compare them.
@@ -33,25 +32,25 @@ function main(conf) {
// alice_secret and bob_secret should be the same
assert(alice_secret === bob_secret);
- const alice_cipher = crypto.createCipher(conf.cipher, alice_secret);
- const bob_cipher = crypto.createDecipher(conf.cipher, bob_secret);
+ const alice_cipher = crypto.createCipher(cipher, alice_secret);
+ const bob_cipher = crypto.createDecipher(cipher, bob_secret);
var message;
var encoding;
- switch (conf.type) {
+ switch (type) {
case 'asc':
- message = 'a'.repeat(conf.len);
+ message = 'a'.repeat(len);
encoding = 'ascii';
break;
case 'utf':
- message = 'ü'.repeat(conf.len / 2);
+ message = 'ü'.repeat(len / 2);
encoding = 'utf8';
break;
case 'buf':
- message = Buffer.alloc(conf.len, 'b');
+ message = Buffer.alloc(len, 'b');
break;
default:
- throw new Error(`unknown message type: ${conf.type}`);
+ throw new Error(`unknown message type: ${type}`);
}
const fn = api === 'stream' ? streamWrite : legacyWrite;
@@ -59,7 +58,7 @@ function main(conf) {
// write data as fast as possible to alice, and have bob decrypt.
// use old API for comparison to v0.8
bench.start();
- fn(alice_cipher, bob_cipher, message, encoding, conf.writes);
+ fn(alice_cipher, bob_cipher, message, encoding, writes);
}
function streamWrite(alice, bob, message, encoding, writes) {
diff --git a/benchmark/crypto/get-ciphers.js b/benchmark/crypto/get-ciphers.js
index 3f5ad17ad38716..d4c10a2427d360 100644
--- a/benchmark/crypto/get-ciphers.js
+++ b/benchmark/crypto/get-ciphers.js
@@ -7,12 +7,10 @@ const bench = common.createBenchmark(main, {
v: ['crypto', 'tls']
});
-function main(conf) {
- const n = +conf.n;
- const v = conf.v;
+function main({ n, v }) {
const method = require(v).getCiphers;
var i = 0;
- // first call to getChipers will dominate the results
+ // First call to getChipers will dominate the results
if (n > 1) {
for (; i < n; i++)
method();
diff --git a/benchmark/crypto/hash-stream-creation.js b/benchmark/crypto/hash-stream-creation.js
index 5ac5a4f70b5c55..faaa12a9e5d484 100644
--- a/benchmark/crypto/hash-stream-creation.js
+++ b/benchmark/crypto/hash-stream-creation.js
@@ -13,8 +13,7 @@ const bench = common.createBenchmark(main, {
api: ['legacy', 'stream']
});
-function main(conf) {
- var api = conf.api;
+function main({ api, type, len, out, writes, algo }) {
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
console.error('Crypto streams not available until v0.10');
// use the legacy, just so that we can compare them.
@@ -23,26 +22,26 @@ function main(conf) {
var message;
var encoding;
- switch (conf.type) {
+ switch (type) {
case 'asc':
- message = 'a'.repeat(conf.len);
+ message = 'a'.repeat(len);
encoding = 'ascii';
break;
case 'utf':
- message = 'ü'.repeat(conf.len / 2);
+ message = 'ü'.repeat(len / 2);
encoding = 'utf8';
break;
case 'buf':
- message = Buffer.alloc(conf.len, 'b');
+ message = Buffer.alloc(len, 'b');
break;
default:
- throw new Error(`unknown message type: ${conf.type}`);
+ throw new Error(`unknown message type: ${type}`);
}
const fn = api === 'stream' ? streamWrite : legacyWrite;
bench.start();
- fn(conf.algo, message, encoding, conf.writes, conf.len, conf.out);
+ fn(algo, message, encoding, writes, len, out);
}
function legacyWrite(algo, message, encoding, writes, len, outEnc) {
diff --git a/benchmark/crypto/hash-stream-throughput.js b/benchmark/crypto/hash-stream-throughput.js
index 21ec3c7902b367..934e7a0b11bdae 100644
--- a/benchmark/crypto/hash-stream-throughput.js
+++ b/benchmark/crypto/hash-stream-throughput.js
@@ -12,8 +12,7 @@ const bench = common.createBenchmark(main, {
api: ['legacy', 'stream']
});
-function main(conf) {
- var api = conf.api;
+function main({ api, type, len, algo, writes }) {
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
console.error('Crypto streams not available until v0.10');
// use the legacy, just so that we can compare them.
@@ -22,26 +21,26 @@ function main(conf) {
var message;
var encoding;
- switch (conf.type) {
+ switch (type) {
case 'asc':
- message = 'a'.repeat(conf.len);
+ message = 'a'.repeat(len);
encoding = 'ascii';
break;
case 'utf':
- message = 'ü'.repeat(conf.len / 2);
+ message = 'ü'.repeat(len / 2);
encoding = 'utf8';
break;
case 'buf':
- message = Buffer.alloc(conf.len, 'b');
+ message = Buffer.alloc(len, 'b');
break;
default:
- throw new Error(`unknown message type: ${conf.type}`);
+ throw new Error(`unknown message type: ${type}`);
}
const fn = api === 'stream' ? streamWrite : legacyWrite;
bench.start();
- fn(conf.algo, message, encoding, conf.writes, conf.len);
+ fn(algo, message, encoding, writes, len);
}
function legacyWrite(algo, message, encoding, writes, len) {
diff --git a/benchmark/crypto/rsa-encrypt-decrypt-throughput.js b/benchmark/crypto/rsa-encrypt-decrypt-throughput.js
index edab5ae08f7d63..40b69c31f977ca 100644
--- a/benchmark/crypto/rsa-encrypt-decrypt-throughput.js
+++ b/benchmark/crypto/rsa-encrypt-decrypt-throughput.js
@@ -22,10 +22,10 @@ const bench = common.createBenchmark(main, {
len: [16, 32, 64]
});
-function main(conf) {
- const message = Buffer.alloc(conf.len, 'b');
+function main({ len, algo, keylen, n }) {
+ const message = Buffer.alloc(len, 'b');
bench.start();
- StreamWrite(conf.algo, conf.keylen, message, conf.n, conf.len);
+ StreamWrite(algo, keylen, message, n, len);
}
function StreamWrite(algo, keylen, message, n, len) {
diff --git a/benchmark/crypto/rsa-sign-verify-throughput.js b/benchmark/crypto/rsa-sign-verify-throughput.js
index bcde3a43d4d77a..3a0373b57d0bba 100644
--- a/benchmark/crypto/rsa-sign-verify-throughput.js
+++ b/benchmark/crypto/rsa-sign-verify-throughput.js
@@ -23,10 +23,10 @@ const bench = common.createBenchmark(main, {
len: [1024, 102400, 2 * 102400, 3 * 102400, 1024 * 1024]
});
-function main(conf) {
- const message = Buffer.alloc(conf.len, 'b');
+function main({ len, algo, keylen, writes }) {
+ const message = Buffer.alloc(len, 'b');
bench.start();
- StreamWrite(conf.algo, conf.keylen, message, conf.writes, conf.len);
+ StreamWrite(algo, keylen, message, writes, len);
}
function StreamWrite(algo, keylen, message, writes, len) {
diff --git a/benchmark/dgram/bind-params.js b/benchmark/dgram/bind-params.js
index 5f7999f7a39241..ea1f430eed929b 100644
--- a/benchmark/dgram/bind-params.js
+++ b/benchmark/dgram/bind-params.js
@@ -15,10 +15,11 @@ const noop = () => {};
function main({ n, port, address }) {
port = port === 'true' ? 0 : undefined;
address = address === 'true' ? '0.0.0.0' : undefined;
+ var i;
if (port !== undefined && address !== undefined) {
bench.start();
- for (let i = 0; i < n; i++) {
+ for (i = 0; i < n; i++) {
dgram.createSocket('udp4').bind(port, address)
.on('error', noop)
.unref();
@@ -26,7 +27,7 @@ function main({ n, port, address }) {
bench.end(n);
} else if (port !== undefined) {
bench.start();
- for (let i = 0; i < n; i++) {
+ for (i = 0; i < n; i++) {
dgram.createSocket('udp4')
.bind(port)
.on('error', noop)
@@ -35,7 +36,7 @@ function main({ n, port, address }) {
bench.end(n);
} else if (port === undefined && address === undefined) {
bench.start();
- for (let i = 0; i < n; i++) {
+ for (i = 0; i < n; i++) {
dgram.createSocket('udp4')
.bind()
.on('error', noop)
diff --git a/benchmark/domain/domain-fn-args.js b/benchmark/domain/domain-fn-args.js
index fe912e34d206e8..c889b35442d046 100644
--- a/benchmark/domain/domain-fn-args.js
+++ b/benchmark/domain/domain-fn-args.js
@@ -28,15 +28,6 @@ function main({ n, args }) {
bench.end(n);
}
-function fn(a, b, c) {
- if (!a)
- a = 1;
-
- if (!b)
- b = 2;
-
- if (!c)
- c = 3;
-
+function fn(a = 1, b = 2, c = 3) {
return a + b + c;
}
diff --git a/benchmark/es/defaultparams-bench.js b/benchmark/es/defaultparams-bench.js
index ce2132718ca369..a00b50137c1af3 100644
--- a/benchmark/es/defaultparams-bench.js
+++ b/benchmark/es/defaultparams-bench.js
@@ -20,37 +20,31 @@ function defaultParams(x = 1, y = 2) {
assert.strictEqual(y, 2);
}
-function runOldStyleDefaults(n) {
-
- var i = 0;
+function runOldStyleDefaults(millions) {
bench.start();
- for (; i < n; i++)
+ for (var i = 0; i < millions * 1e6; i++)
oldStyleDefaults();
- bench.end(n / 1e6);
+ bench.end(millions);
}
-function runDefaultParams(n) {
-
- var i = 0;
+function runDefaultParams(millions) {
bench.start();
- for (; i < n; i++)
+ for (var i = 0; i < millions * 1e6; i++)
defaultParams();
- bench.end(n / 1e6);
+ bench.end(millions);
}
function main({ millions, method }) {
- const n = millions * 1e6;
-
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'withoutdefaults':
- runOldStyleDefaults(n);
+ runOldStyleDefaults(millions);
break;
case 'withdefaults':
- runDefaultParams(n);
+ runDefaultParams(millions);
break;
default:
- throw new Error('Unexpected method');
+ throw new Error(`Unexpected method "${method}"`);
}
}
diff --git a/benchmark/es/destructuring-bench.js b/benchmark/es/destructuring-bench.js
index f244506860d248..2168940bdc44f0 100644
--- a/benchmark/es/destructuring-bench.js
+++ b/benchmark/es/destructuring-bench.js
@@ -8,10 +8,10 @@ const bench = common.createBenchmark(main, {
millions: [100]
});
-function runSwapManual(n) {
+function runSwapManual(millions) {
var x, y, r;
bench.start();
- for (var i = 0; i < n; i++) {
+ for (var i = 0; i < millions * 1e6; i++) {
x = 1, y = 2;
r = x;
x = y;
@@ -19,34 +19,32 @@ function runSwapManual(n) {
assert.strictEqual(x, 2);
assert.strictEqual(y, 1);
}
- bench.end(n / 1e6);
+ bench.end(millions);
}
-function runSwapDestructured(n) {
+function runSwapDestructured(millions) {
var x, y;
bench.start();
- for (var i = 0; i < n; i++) {
+ for (var i = 0; i < millions * 1e6; i++) {
x = 1, y = 2;
[x, y] = [y, x];
assert.strictEqual(x, 2);
assert.strictEqual(y, 1);
}
- bench.end(n / 1e6);
+ bench.end(millions);
}
function main({ millions, method }) {
- const n = millions * 1e6;
-
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'swap':
- runSwapManual(n);
+ runSwapManual(millions);
break;
case 'destructure':
- runSwapDestructured(n);
+ runSwapDestructured(millions);
break;
default:
- throw new Error('Unexpected method');
+ throw new Error(`Unexpected method "${method}"`);
}
}
diff --git a/benchmark/es/destructuring-object-bench.js b/benchmark/es/destructuring-object-bench.js
index 73687f018de9dd..a84977c59bc2cd 100644
--- a/benchmark/es/destructuring-object-bench.js
+++ b/benchmark/es/destructuring-object-bench.js
@@ -7,45 +7,43 @@ const bench = common.createBenchmark(main, {
millions: [100]
});
-function runNormal(n) {
+function runNormal(millions) {
var i = 0;
const o = { x: 0, y: 1 };
bench.start();
- for (; i < n; i++) {
+ for (; i < millions * 1e6; i++) {
/* eslint-disable no-unused-vars */
const x = o.x;
const y = o.y;
const r = o.r || 2;
/* eslint-enable no-unused-vars */
}
- bench.end(n / 1e6);
+ bench.end(millions);
}
-function runDestructured(n) {
+function runDestructured(millions) {
var i = 0;
const o = { x: 0, y: 1 };
bench.start();
- for (; i < n; i++) {
+ for (; i < millions * 1e6; i++) {
/* eslint-disable no-unused-vars */
const { x, y, r = 2 } = o;
/* eslint-enable no-unused-vars */
}
- bench.end(n / 1e6);
+ bench.end(millions);
}
function main({ millions, method }) {
- const n = millions * 1e6;
-
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'normal':
- runNormal(n);
+ runNormal(millions);
break;
case 'destructureObject':
- runDestructured(n);
+ runDestructured(millions);
break;
default:
- throw new Error('Unexpected method');
+ throw new Error(`Unexpected method "${method}"`);
}
}
diff --git a/benchmark/es/foreach-bench.js b/benchmark/es/foreach-bench.js
index c7caa7cee6f461..e9179ed8dedb6d 100644
--- a/benchmark/es/foreach-bench.js
+++ b/benchmark/es/foreach-bench.js
@@ -8,56 +8,51 @@ const bench = common.createBenchmark(main, {
millions: [5]
});
-function useFor(n, items, count) {
- var i, j;
+function useFor(millions, items, count) {
bench.start();
- for (i = 0; i < n; i++) {
- for (j = 0; j < count; j++) {
+ for (var i = 0; i < millions * 1e6; i++) {
+ for (var j = 0; j < count; j++) {
/* eslint-disable no-unused-vars */
const item = items[j];
/* esline-enable no-unused-vars */
}
}
- bench.end(n / 1e6);
+ bench.end(millions);
}
-function useForOf(n, items) {
- var i, item;
+function useForOf(millions, items) {
+ var item;
bench.start();
- for (i = 0; i < n; i++) {
+ for (var i = 0; i < millions * 1e6; i++) {
for (item of items) {}
}
- bench.end(n / 1e6);
+ bench.end(millions);
}
-function useForIn(n, items) {
- var i, j, item;
+function useForIn(millions, items) {
bench.start();
- for (i = 0; i < n; i++) {
- for (j in items) {
+ for (var i = 0; i < millions * 1e6; i++) {
+ for (var j in items) {
/* eslint-disable no-unused-vars */
- item = items[j];
+ const item = items[j];
/* esline-enable no-unused-vars */
}
}
- bench.end(n / 1e6);
+ bench.end(millions);
}
-function useForEach(n, items) {
- var i;
+function useForEach(millions, items) {
bench.start();
- for (i = 0; i < n; i++) {
+ for (var i = 0; i < millions * 1e6; i++) {
items.forEach((item) => {});
}
- bench.end(n / 1e6);
+ bench.end(millions);
}
function main({ millions, count, method }) {
- const n = millions * 1e6;
const items = new Array(count);
- var i;
var fn;
- for (i = 0; i < count; i++)
+ for (var i = 0; i < count; i++)
items[i] = i;
switch (method) {
@@ -76,7 +71,7 @@ function main({ millions, count, method }) {
fn = useForEach;
break;
default:
- throw new Error('Unexpected method');
+ throw new Error(`Unexpected method "${method}"`);
}
- fn(n, items, count);
+ fn(millions, items, count);
}
diff --git a/benchmark/es/map-bench.js b/benchmark/es/map-bench.js
index ba8e35c2eb934f..445031aa9831de 100644
--- a/benchmark/es/map-bench.js
+++ b/benchmark/es/map-bench.js
@@ -11,63 +11,59 @@ const bench = common.createBenchmark(main, {
millions: [1]
});
-function runObject(n) {
+function runObject(millions) {
const m = {};
- var i = 0;
bench.start();
- for (; i < n; i++) {
+ for (var i = 0; i < millions * 1e6; i++) {
m[`i${i}`] = i;
m[`s${i}`] = String(i);
assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]);
m[`i${i}`] = undefined;
m[`s${i}`] = undefined;
}
- bench.end(n / 1e6);
+ bench.end(millions);
}
-function runNullProtoObject(n) {
+function runNullProtoObject(millions) {
const m = Object.create(null);
- var i = 0;
bench.start();
- for (; i < n; i++) {
+ for (var i = 0; i < millions * 1e6; i++) {
m[`i${i}`] = i;
m[`s${i}`] = String(i);
assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]);
m[`i${i}`] = undefined;
m[`s${i}`] = undefined;
}
- bench.end(n / 1e6);
+ bench.end(millions);
}
-function runNullProtoLiteralObject(n) {
+function runNullProtoLiteralObject(millions) {
const m = { __proto__: null };
- var i = 0;
bench.start();
- for (; i < n; i++) {
+ for (var i = 0; i < millions * 1e6; i++) {
m[`i${i}`] = i;
m[`s${i}`] = String(i);
assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]);
m[`i${i}`] = undefined;
m[`s${i}`] = undefined;
}
- bench.end(n / 1e6);
+ bench.end(millions);
}
function StorageObject() {}
StorageObject.prototype = Object.create(null);
-function runStorageObject(n) {
+function runStorageObject(millions) {
const m = new StorageObject();
- var i = 0;
bench.start();
- for (; i < n; i++) {
+ for (var i = 0; i < millions * 1e6; i++) {
m[`i${i}`] = i;
m[`s${i}`] = String(i);
assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]);
m[`i${i}`] = undefined;
m[`s${i}`] = undefined;
}
- bench.end(n / 1e6);
+ bench.end(millions);
}
function fakeMap() {
@@ -80,59 +76,55 @@ function fakeMap() {
};
}
-function runFakeMap(n) {
+function runFakeMap(millions) {
const m = fakeMap();
- var i = 0;
bench.start();
- for (; i < n; i++) {
+ for (var i = 0; i < millions * 1e6; i++) {
m.set(`i${i}`, i);
m.set(`s${i}`, String(i));
assert.strictEqual(String(m.get(`i${i}`)), m.get(`s${i}`));
m.set(`i${i}`, undefined);
m.set(`s${i}`, undefined);
}
- bench.end(n / 1e6);
+ bench.end(millions);
}
-function runMap(n) {
+function runMap(millions) {
const m = new Map();
- var i = 0;
bench.start();
- for (; i < n; i++) {
+ for (var i = 0; i < millions * 1e6; i++) {
m.set(`i${i}`, i);
m.set(`s${i}`, String(i));
assert.strictEqual(String(m.get(`i${i}`)), m.get(`s${i}`));
m.set(`i${i}`, undefined);
m.set(`s${i}`, undefined);
}
- bench.end(n / 1e6);
+ bench.end(millions);
}
function main({ millions, method }) {
- const n = millions * 1e6;
-
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'object':
- runObject(n);
+ runObject(millions);
break;
case 'nullProtoObject':
- runNullProtoObject(n);
+ runNullProtoObject(millions);
break;
case 'nullProtoLiteralObject':
- runNullProtoLiteralObject(n);
+ runNullProtoLiteralObject(millions);
break;
case 'storageObject':
- runStorageObject(n);
+ runStorageObject(millions);
break;
case 'fakeMap':
- runFakeMap(n);
+ runFakeMap(millions);
break;
case 'map':
- runMap(n);
+ runMap(millions);
break;
default:
- throw new Error('Unexpected method');
+ throw new Error(`Unexpected method "${method}"`);
}
}
diff --git a/benchmark/es/restparams-bench.js b/benchmark/es/restparams-bench.js
index 78299d292ce6f6..6ad766f10f16f6 100644
--- a/benchmark/es/restparams-bench.js
+++ b/benchmark/es/restparams-bench.js
@@ -33,49 +33,39 @@ function useArguments() {
assert.strictEqual(arguments[3], 'b');
}
-function runCopyArguments(n) {
-
- var i = 0;
- bench.start();
- for (; i < n; i++)
+function runCopyArguments(millions) {
+ for (var i = 0; i < millions * 1e6; i++)
copyArguments(1, 2, 'a', 'b');
- bench.end(n / 1e6);
}
-function runRestArguments(n) {
-
- var i = 0;
- bench.start();
- for (; i < n; i++)
+function runRestArguments(millions) {
+ for (var i = 0; i < millions * 1e6; i++)
restArguments(1, 2, 'a', 'b');
- bench.end(n / 1e6);
}
-function runUseArguments(n) {
-
- var i = 0;
- bench.start();
- for (; i < n; i++)
+function runUseArguments(millions) {
+ for (var i = 0; i < millions * 1e6; i++)
useArguments(1, 2, 'a', 'b');
- bench.end(n / 1e6);
}
function main({ millions, method }) {
- const n = millions * 1e6;
-
+ var fn;
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'copy':
- runCopyArguments(n);
+ fn = runCopyArguments;
break;
case 'rest':
- runRestArguments(n);
+ fn = runRestArguments;
break;
case 'arguments':
- runUseArguments(n);
+ fn = runUseArguments;
break;
default:
- throw new Error('Unexpected method');
+ throw new Error(`Unexpected method "${method}"`);
}
+ bench.start();
+ fn(millions);
+ bench.end(millions);
}
diff --git a/benchmark/es/spread-assign.js b/benchmark/es/spread-assign.js
new file mode 100644
index 00000000000000..00c634ff879501
--- /dev/null
+++ b/benchmark/es/spread-assign.js
@@ -0,0 +1,46 @@
+'use strict';
+
+const common = require('../common.js');
+const util = require('util');
+
+const bench = common.createBenchmark(main, {
+ method: ['spread', 'assign', '_extend'],
+ count: [5, 10, 20],
+ millions: [1]
+});
+
+function main({ millions, context, count, rest, method }) {
+ const n = millions * 1e6;
+
+ const src = {};
+ for (let n = 0; n < count; n++)
+ src[`p${n}`] = n;
+
+ let obj; // eslint-disable-line
+ let i;
+
+ switch (method) {
+ case '':
+ // Empty string falls through to next line as default, mostly for tests.
+ case '_extend':
+ bench.start();
+ for (i = 0; i < n; i++)
+ obj = util._extend({}, src);
+ bench.end(n);
+ break;
+ case 'assign':
+ bench.start();
+ for (i = 0; i < n; i++)
+ obj = Object.assign({}, src);
+ bench.end(n);
+ break;
+ case 'spread':
+ bench.start();
+ for (i = 0; i < n; i++)
+ obj = { ...src };
+ bench.end(n);
+ break;
+ default:
+ throw new Error('Unexpected method');
+ }
+}
diff --git a/benchmark/es/spread-bench.js b/benchmark/es/spread-bench.js
index 3c6cc93ea4f817..067299cd650919 100644
--- a/benchmark/es/spread-bench.js
+++ b/benchmark/es/spread-bench.js
@@ -24,7 +24,6 @@ function makeTest(count, rest) {
}
function main({ millions, context, count, rest, method }) {
- const n = millions * 1e6;
const ctx = context === 'context' ? {} : null;
var fn = makeTest(count, rest);
const args = new Array(count);
@@ -37,25 +36,25 @@ function main({ millions, context, count, rest, method }) {
// Empty string falls through to next line as default, mostly for tests.
case 'apply':
bench.start();
- for (i = 0; i < n; i++)
+ for (i = 0; i < millions * 1e6; i++)
fn.apply(ctx, args);
- bench.end(n / 1e6);
+ bench.end(millions);
break;
case 'spread':
if (ctx !== null)
fn = fn.bind(ctx);
bench.start();
- for (i = 0; i < n; i++)
+ for (i = 0; i < millions * 1e6; i++)
fn(...args);
- bench.end(n / 1e6);
+ bench.end(millions);
break;
case 'call-spread':
bench.start();
- for (i = 0; i < n; i++)
+ for (i = 0; i < millions * 1e6; i++)
fn.call(ctx, ...args);
- bench.end(n / 1e6);
+ bench.end(millions);
break;
default:
- throw new Error('Unexpected method');
+ throw new Error(`Unexpected method "${method}"`);
}
}
diff --git a/benchmark/es/string-concatenations.js b/benchmark/es/string-concatenations.js
index a40b7fa8c3b9f9..72fb7f9969b604 100644
--- a/benchmark/es/string-concatenations.js
+++ b/benchmark/es/string-concatenations.js
@@ -16,7 +16,6 @@ const configs = {
const bench = common.createBenchmark(main, configs);
-
function main({ n, mode }) {
const str = 'abc';
const num = 123;
@@ -63,7 +62,7 @@ function main({ n, mode }) {
bench.end(n);
break;
default:
- throw new Error('Unexpected method');
+ throw new Error(`Unexpected method "${mode}"`);
}
return string;
diff --git a/benchmark/es/string-repeat.js b/benchmark/es/string-repeat.js
index e5bdbb5cc193c1..9e33e4acf47118 100644
--- a/benchmark/es/string-repeat.js
+++ b/benchmark/es/string-repeat.js
@@ -33,7 +33,7 @@ function main({ n, size, encoding, mode }) {
bench.end(n);
break;
default:
- throw new Error('Unexpected method');
+ throw new Error(`Unexpected method "${mode}"`);
}
assert.strictEqual([...str].length, size);
diff --git a/benchmark/fs/bench-realpath.js b/benchmark/fs/bench-realpath.js
index 6690d7e87b091f..de03e71b42d585 100644
--- a/benchmark/fs/bench-realpath.js
+++ b/benchmark/fs/bench-realpath.js
@@ -16,10 +16,8 @@ function main({ n, pathType }) {
bench.start();
if (pathType === 'relative')
relativePath(n);
- else if (pathType === 'resolved')
- resolvedPath(n);
else
- throw new Error(`unknown "pathType": ${pathType}`);
+ resolvedPath(n);
}
function relativePath(n) {
diff --git a/benchmark/fs/bench-realpathSync.js b/benchmark/fs/bench-realpathSync.js
index 1c751156f73d53..7a01bd18cb72bf 100644
--- a/benchmark/fs/bench-realpathSync.js
+++ b/benchmark/fs/bench-realpathSync.js
@@ -15,24 +15,10 @@ const bench = common.createBenchmark(main, {
function main({ n, pathType }) {
+ const path = pathType === 'relative' ? relative_path : resolved_path;
bench.start();
- if (pathType === 'relative')
- relativePath(n);
- else if (pathType === 'resolved')
- resolvedPath(n);
- else
- throw new Error(`unknown "pathType": ${pathType}`);
- bench.end(n);
-}
-
-function relativePath(n) {
- for (var i = 0; i < n; i++) {
- fs.realpathSync(relative_path);
- }
-}
-
-function resolvedPath(n) {
for (var i = 0; i < n; i++) {
- fs.realpathSync(resolved_path);
+ fs.realpathSync(path);
}
+ bench.end(n);
}
diff --git a/benchmark/fs/write-stream-throughput.js b/benchmark/fs/write-stream-throughput.js
index 6fe00cde48cabb..60ad47bc4eabe1 100644
--- a/benchmark/fs/write-stream-throughput.js
+++ b/benchmark/fs/write-stream-throughput.js
@@ -36,7 +36,6 @@ function main({ dur, encodingType, size }) {
try { fs.unlinkSync(filename); } catch (e) {}
var started = false;
- var ending = false;
var ended = false;
var f = fs.createWriteStream(filename);
@@ -52,15 +51,9 @@ function main({ dur, encodingType, size }) {
function write() {
- // don't try to write after we end, even if a 'drain' event comes.
- // v0.8 streams are so sloppy!
- if (ending)
- return;
-
if (!started) {
started = true;
setTimeout(function() {
- ending = true;
f.end();
}, dur * 1000);
bench.start();
diff --git a/benchmark/http/bench-parser.js b/benchmark/http/bench-parser.js
index 4c691d71345da3..d629fe67e59e76 100644
--- a/benchmark/http/bench-parser.js
+++ b/benchmark/http/bench-parser.js
@@ -14,7 +14,6 @@ const bench = common.createBenchmark(main, {
n: [1e5],
});
-
function main({ len, n }) {
var header = `GET /hello HTTP/1.1${CRLF}Content-Type: text/plain${CRLF}`;
@@ -26,7 +25,6 @@ function main({ len, n }) {
processHeader(Buffer.from(header), n);
}
-
function processHeader(header, n) {
const parser = newParser(REQUEST);
@@ -38,7 +36,6 @@ function processHeader(header, n) {
bench.end(n);
}
-
function newParser(type) {
const parser = new HTTPParser(type);
diff --git a/benchmark/http/check_invalid_header_char.js b/benchmark/http/check_invalid_header_char.js
index b9933d690e25cc..c70b0d39db2ffc 100644
--- a/benchmark/http/check_invalid_header_char.js
+++ b/benchmark/http/check_invalid_header_char.js
@@ -3,37 +3,66 @@
const common = require('../common.js');
const _checkInvalidHeaderChar = require('_http_common')._checkInvalidHeaderChar;
-const bench = common.createBenchmark(main, {
- key: [
- // Valid
- '',
- '1',
- '\t\t\t\t\t\t\t\t\t\tFoo bar baz',
- 'keep-alive',
- 'close',
- 'gzip',
- '20091',
- 'private',
- 'text/html; charset=utf-8',
- 'text/plain',
- 'Sat, 07 May 2016 16:54:48 GMT',
- 'SAMEORIGIN',
- 'en-US',
-
- // Invalid
- 'Here is a value that is really a folded header value\r\n this should be \
- supported, but it is not currently',
- '中文呢', // unicode
- 'foo\nbar',
- '\x7F'
+const groupedInputs = {
+ // Representative set of inputs from an AcmeAir benchmark run:
+ // all valid strings, average length 14.4, stdev 13.0
+ group_acmeair: [
+ 'W/"2-d4cbb29"', 'OK', 'Express', 'X-HTTP-Method-Override', 'Express',
+ 'application/json', 'application/json; charset=utf-8', '206', 'OK',
+ 'sessionid=; Path=/', 'text/html; charset=utf-8',
+ 'text/html; charset=utf-8', '10', 'W/"a-eda64de5"', 'OK', 'Express',
+ 'application/json', 'application/json; charset=utf-8', '2', 'W/"2-d4cbb29"',
+ 'OK', 'Express', 'X-HTTP-Method-Override', 'sessionid=; Path=/', 'Express',
+ 'sessionid=; Path=/,sessionid=6b059402-d62f-4e6f-b3dd-ce5b9e487c39; Path=/',
+ 'text/html; charset=utf-8', 'text/html; charset=utf-8', '9', 'OK',
+ 'sessionid=; Path=/', 'text/html; charset=utf-8',
+ 'text/html; charset=utf-8', '10', 'W/"a-eda64de5"', 'OK', 'Express',
+ 'Express', 'X-HTTP-Method-Override', 'sessionid=; Path=/',
+ 'application/json'
],
+
+ // Put it here so the benchmark result lines will not be super long.
+ LONG_AND_INVALID: ['Here is a value that is really a folded header ' +
+ 'value\r\n this should be supported, but it is not currently']
+};
+
+const inputs = [
+ // Valid
+ '',
+ '1',
+ '\t\t\t\t\t\t\t\t\t\tFoo bar baz',
+ 'keep-alive',
+ 'close',
+ 'gzip',
+ '20091',
+ 'private',
+ 'text/html; charset=utf-8',
+ 'text/plain',
+ 'Sat, 07 May 2016 16:54:48 GMT',
+ 'SAMEORIGIN',
+ 'en-US',
+
+ // Invalid
+ '中文呢', // unicode
+ 'foo\nbar',
+ '\x7F'
+];
+
+const bench = common.createBenchmark(main, {
+ input: inputs.concat(Object.keys(groupedInputs)),
n: [1e6],
});
-function main({ n, key }) {
+function main({ n, input }) {
+ let inputs = [input];
+ if (groupedInputs.hasOwnProperty(input)) {
+ inputs = groupedInputs[input];
+ }
+
+ const len = inputs.length;
bench.start();
for (var i = 0; i < n; i++) {
- _checkInvalidHeaderChar(key);
+ _checkInvalidHeaderChar(inputs[i % len]);
}
bench.end(n);
}
diff --git a/benchmark/http/http_server_for_chunky_client.js b/benchmark/http/http_server_for_chunky_client.js
index f079544e03d48e..1e5a4583669c0f 100644
--- a/benchmark/http/http_server_for_chunky_client.js
+++ b/benchmark/http/http_server_for_chunky_client.js
@@ -2,22 +2,15 @@
const assert = require('assert');
const http = require('http');
-const fs = require('fs');
const { fork } = require('child_process');
const common = require('../common.js');
-const { PIPE, tmpDir } = require('../../test/common');
+const { PIPE } = require('../../test/common');
+const tmpdir = require('../../test/common/tmpdir');
process.env.PIPE_NAME = PIPE;
-try {
- fs.accessSync(tmpDir, fs.F_OK);
-} catch (e) {
- fs.mkdirSync(tmpDir);
-}
+tmpdir.refresh();
var server;
-try {
- fs.unlinkSync(process.env.PIPE_NAME);
-} catch (e) { /* ignore */ }
server = http.createServer(function(req, res) {
const headers = {
diff --git a/benchmark/http/set-header.js b/benchmark/http/set-header.js
new file mode 100644
index 00000000000000..f0987f2cc77150
--- /dev/null
+++ b/benchmark/http/set-header.js
@@ -0,0 +1,32 @@
+'use strict';
+const common = require('../common.js');
+const PORT = common.PORT;
+
+const bench = common.createBenchmark(main, {
+ res: ['normal', 'setHeader', 'setHeaderWH']
+});
+
+const type = 'bytes';
+const len = 4;
+const chunks = 0;
+const chunkedEnc = 0;
+const c = 50;
+
+// normal: writeHead(status, {...})
+// setHeader: statusCode = status, setHeader(...) x2
+// setHeaderWH: setHeader(...), writeHead(status, ...)
+function main({ res }) {
+ process.env.PORT = PORT;
+ var server = require('../fixtures/simple-http-server.js')
+ .listen(PORT)
+ .on('listening', function() {
+ const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`;
+
+ bench.http({
+ path: path,
+ connections: c
+ }, function() {
+ server.close();
+ });
+ });
+}
diff --git a/benchmark/http/set_header.js b/benchmark/http/set_header.js
new file mode 100644
index 00000000000000..22de61b3f847a3
--- /dev/null
+++ b/benchmark/http/set_header.js
@@ -0,0 +1,30 @@
+'use strict';
+
+const common = require('../common.js');
+const { OutgoingMessage } = require('_http_outgoing');
+
+const bench = common.createBenchmark(main, {
+ value: [
+ 'X-Powered-By',
+ 'Vary',
+ 'Set-Cookie',
+ 'Content-Type',
+ 'Content-Length',
+ 'Connection',
+ 'Transfer-Encoding'
+ ],
+ n: [1e6],
+});
+
+function main(conf) {
+ const n = +conf.n;
+ const value = conf.value;
+
+ const og = new OutgoingMessage();
+
+ bench.start();
+ for (var i = 0; i < n; i++) {
+ og.setHeader(value, '');
+ }
+ bench.end(n);
+}
diff --git a/benchmark/http/simple.js b/benchmark/http/simple.js
index d5351815fc1b7e..6d1851c45e17b2 100644
--- a/benchmark/http/simple.js
+++ b/benchmark/http/simple.js
@@ -1,6 +1,5 @@
'use strict';
const common = require('../common.js');
-const PORT = common.PORT;
const bench = common.createBenchmark(main, {
// unicode confuses ab on os x.
@@ -8,16 +7,14 @@ const bench = common.createBenchmark(main, {
len: [4, 1024, 102400],
chunks: [1, 4],
c: [50, 500],
- chunkedEnc: [1, 0],
- res: ['normal', 'setHeader', 'setHeaderWH']
+ chunkedEnc: [1, 0]
});
function main({ type, len, chunks, c, chunkedEnc, res }) {
- process.env.PORT = PORT;
var server = require('../fixtures/simple-http-server.js')
- .listen(PORT)
+ .listen(common.PORT)
.on('listening', function() {
- const path = `/${type}/${len}/${chunks}/${res}/${chunkedEnc}`;
+ const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`;
bench.http({
path: path,
diff --git a/benchmark/http/upgrade.js b/benchmark/http/upgrade.js
index 0feaecc8ff19e6..6b39323396a2e3 100644
--- a/benchmark/http/upgrade.js
+++ b/benchmark/http/upgrade.js
@@ -1,7 +1,6 @@
'use strict';
const common = require('../common.js');
-const PORT = common.PORT;
const net = require('net');
const bench = common.createBenchmark(main, {
@@ -20,7 +19,6 @@ const resData = 'HTTP/1.1 101 Web Socket Protocol Handshake\r\n' +
'\r\n\r\n';
function main({ n }) {
- process.env.PORT = PORT;
var server = require('../fixtures/simple-http-server.js')
.listen(common.PORT)
.on('listening', function() {
diff --git a/benchmark/http2/respond-with-fd.js b/benchmark/http2/respond-with-fd.js
index 6076cf91be9d84..fa7b2fbd16b3e6 100644
--- a/benchmark/http2/respond-with-fd.js
+++ b/benchmark/http2/respond-with-fd.js
@@ -1,7 +1,6 @@
'use strict';
const common = require('../common.js');
-const PORT = common.PORT;
const path = require('path');
const fs = require('fs');
@@ -25,7 +24,7 @@ function main({ requests, streams, clients }) {
stream.respondWithFD(fd);
stream.on('error', (err) => {});
});
- server.listen(PORT, () => {
+ server.listen(common.PORT, () => {
bench.http({
path: '/',
requests,
diff --git a/benchmark/http2/simple.js b/benchmark/http2/simple.js
index 37c78d340181a8..cf017e6735411e 100644
--- a/benchmark/http2/simple.js
+++ b/benchmark/http2/simple.js
@@ -1,11 +1,8 @@
'use strict';
const common = require('../common.js');
-const PORT = common.PORT;
-
const path = require('path');
const fs = require('fs');
-
const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html');
const bench = common.createBenchmark(main, {
@@ -24,7 +21,7 @@ function main({ requests, streams, clients }) {
out.pipe(stream);
stream.on('error', (err) => {});
});
- server.listen(PORT, () => {
+ server.listen(common.PORT, () => {
bench.http({
path: '/',
requests,
diff --git a/benchmark/http2/write.js b/benchmark/http2/write.js
index 7a802ef84fd9ed..6fcb1254ca3f05 100644
--- a/benchmark/http2/write.js
+++ b/benchmark/http2/write.js
@@ -1,7 +1,6 @@
'use strict';
const common = require('../common.js');
-const PORT = common.PORT;
const bench = common.createBenchmark(main, {
streams: [100, 200, 1000],
@@ -26,7 +25,7 @@ function main({ streams, length, size }) {
}
write();
});
- server.listen(PORT, () => {
+ server.listen(common.PORT, () => {
bench.http({
path: '/',
requests: 10000,
diff --git a/benchmark/misc/freelist.js b/benchmark/misc/freelist.js
index 0530255728ffeb..8c3281cc407363 100644
--- a/benchmark/misc/freelist.js
+++ b/benchmark/misc/freelist.js
@@ -12,7 +12,6 @@ function main({ n }) {
const FreeList = require('internal/freelist');
const poolSize = 1000;
const list = new FreeList('test', poolSize, Object);
- var i;
var j;
const used = [];
@@ -23,7 +22,7 @@ function main({ n }) {
bench.start();
- for (i = 0; i < n; i++) {
+ for (var i = 0; i < n; i++) {
// Return all the items to the pool
for (j = 0; j < poolSize; j++) {
list.free(used[j]);
diff --git a/benchmark/misc/function_call/index.js b/benchmark/misc/function_call/index.js
index 91efa573597cc7..28561bc48cd7c3 100644
--- a/benchmark/misc/function_call/index.js
+++ b/benchmark/misc/function_call/index.js
@@ -32,11 +32,9 @@ const bench = common.createBenchmark(main, {
});
function main({ millions, type }) {
- const n = millions * 1e6;
-
const fn = type === 'cxx' ? cxx : js;
bench.start();
- for (var i = 0; i < n; i++) {
+ for (var i = 0; i < millions * 1e6; i++) {
fn();
}
bench.end(millions);
diff --git a/benchmark/misc/object-property-bench.js b/benchmark/misc/object-property-bench.js
index 37da82d88758fd..3a181ed0a540f8 100644
--- a/benchmark/misc/object-property-bench.js
+++ b/benchmark/misc/object-property-bench.js
@@ -1,5 +1,7 @@
'use strict';
+/* eslint-disable dot-notation */
+
const common = require('../common.js');
const bench = common.createBenchmark(main, {
@@ -78,6 +80,6 @@ function main({ millions, method }) {
runSymbol(n);
break;
default:
- throw new Error('Unexpected method');
+ throw new Error(`Unexpected method "${method}"`);
}
}
diff --git a/benchmark/misc/punycode.js b/benchmark/misc/punycode.js
index 7016fa11712bbc..369adcf17d3973 100644
--- a/benchmark/misc/punycode.js
+++ b/benchmark/misc/punycode.js
@@ -55,9 +55,8 @@ function runPunycode(n, val) {
}
function runICU(n, val) {
- var i = 0;
bench.start();
- for (; i < n; i++)
+ for (var i = 0; i < n; i++)
usingICU(val);
bench.end(n);
}
@@ -76,6 +75,6 @@ function main({ n, val, method }) {
}
// fallthrough
default:
- throw new Error('Unexpected method');
+ throw new Error(`Unexpected method "${method}"`);
}
}
diff --git a/benchmark/module/module-loader.js b/benchmark/module/module-loader.js
index 8393d1f92e0e6c..58d4dcf81c9316 100644
--- a/benchmark/module/module-loader.js
+++ b/benchmark/module/module-loader.js
@@ -3,8 +3,8 @@ const fs = require('fs');
const path = require('path');
const common = require('../common.js');
-const { refreshTmpDir, tmpDir } = require('../../test/common');
-const benchmarkDirectory = path.join(tmpDir, 'nodejs-benchmark-module');
+const tmpdir = require('../../test/common/tmpdir');
+const benchmarkDirectory = path.join(tmpdir.path, 'nodejs-benchmark-module');
const bench = common.createBenchmark(main, {
thousands: [50],
@@ -13,12 +13,10 @@ const bench = common.createBenchmark(main, {
});
function main({ thousands, fullPath, useCache }) {
- const n = thousands * 1e3;
-
- refreshTmpDir();
+ tmpdir.refresh();
try { fs.mkdirSync(benchmarkDirectory); } catch (e) {}
- for (var i = 0; i <= n; i++) {
+ for (var i = 0; i <= thousands * 1e3; i++) {
fs.mkdirSync(`${benchmarkDirectory}${i}`);
fs.writeFileSync(
`${benchmarkDirectory}${i}/package.json`,
@@ -31,37 +29,37 @@ function main({ thousands, fullPath, useCache }) {
}
if (fullPath === 'true')
- measureFull(n, useCache === 'true');
+ measureFull(thousands, useCache === 'true');
else
- measureDir(n, useCache === 'true');
+ measureDir(thousands, useCache === 'true');
- refreshTmpDir();
+ tmpdir.refresh();
}
-function measureFull(n, useCache) {
+function measureFull(thousands, useCache) {
var i;
if (useCache) {
- for (i = 0; i <= n; i++) {
+ for (i = 0; i <= thousands * 1e3; i++) {
require(`${benchmarkDirectory}${i}/index.js`);
}
}
bench.start();
- for (i = 0; i <= n; i++) {
+ for (i = 0; i <= thousands * 1e3; i++) {
require(`${benchmarkDirectory}${i}/index.js`);
}
- bench.end(n / 1e3);
+ bench.end(thousands);
}
-function measureDir(n, useCache) {
+function measureDir(thousands, useCache) {
var i;
if (useCache) {
- for (i = 0; i <= n; i++) {
+ for (i = 0; i <= thousands * 1e3; i++) {
require(`${benchmarkDirectory}${i}`);
}
}
bench.start();
- for (i = 0; i <= n; i++) {
+ for (i = 0; i <= thousands * 1e3; i++) {
require(`${benchmarkDirectory}${i}`);
}
- bench.end(n / 1e3);
+ bench.end(thousands);
}
diff --git a/benchmark/path/basename-win32.js b/benchmark/path/basename-win32.js
index 8a66f56d6e3295..937dc6f6948c5d 100644
--- a/benchmark/path/basename-win32.js
+++ b/benchmark/path/basename-win32.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const { posix } = require('path');
+const { win32 } = require('path');
const bench = common.createBenchmark(main, {
pathext: [
@@ -28,7 +28,7 @@ function main({ n, pathext }) {
bench.start();
for (var i = 0; i < n; i++) {
- posix.basename(pathext, ext);
+ win32.basename(pathext, ext);
}
bench.end(n);
}
diff --git a/benchmark/timers/set-immediate-breadth.js b/benchmark/timers/set-immediate-breadth.js
index a4b217b5bff8d6..4f7d2cd2761334 100644
--- a/benchmark/timers/set-immediate-breadth.js
+++ b/benchmark/timers/set-immediate-breadth.js
@@ -9,7 +9,7 @@ function main({ millions }) {
const N = millions * 1e6;
process.on('exit', function() {
- bench.end(N / 1e6);
+ bench.end(millions);
});
function cb() {}
diff --git a/benchmark/timers/set-immediate-depth-args.js b/benchmark/timers/set-immediate-depth-args.js
index fe1340c4bd55f2..aa5ec95f7dad30 100644
--- a/benchmark/timers/set-immediate-depth-args.js
+++ b/benchmark/timers/set-immediate-depth-args.js
@@ -9,7 +9,7 @@ function main({ millions }) {
const N = millions * 1e6;
process.on('exit', function() {
- bench.end(N / 1e6);
+ bench.end(millions);
});
function cb3(n, arg2, arg3) {
diff --git a/benchmark/timers/timers-cancel-pooled.js b/benchmark/timers/timers-cancel-pooled.js
index 33897507c83937..3e262f820a3e08 100644
--- a/benchmark/timers/timers-cancel-pooled.js
+++ b/benchmark/timers/timers-cancel-pooled.js
@@ -28,5 +28,5 @@ function main({ millions }) {
}
function cb() {
- assert(false, 'Timer should not call callback');
+ assert.fail('Timer should not call callback');
}
diff --git a/benchmark/timers/timers-cancel-unpooled.js b/benchmark/timers/timers-cancel-unpooled.js
index 57e0139dfe1a4a..158667311330a4 100644
--- a/benchmark/timers/timers-cancel-unpooled.js
+++ b/benchmark/timers/timers-cancel-unpooled.js
@@ -22,5 +22,5 @@ function main({ millions }) {
}
function cb() {
- assert(false, `Timer ${this._idleTimeout} should not call callback`);
+ assert.fail(`Timer ${this._idleTimeout} should not call callback`);
}
diff --git a/benchmark/timers/timers-insert-unpooled.js b/benchmark/timers/timers-insert-unpooled.js
index 56526633358e42..fbbeebb759ff3a 100644
--- a/benchmark/timers/timers-insert-unpooled.js
+++ b/benchmark/timers/timers-insert-unpooled.js
@@ -23,5 +23,5 @@ function main({ millions }) {
}
function cb() {
- assert(false, `Timer ${this._idleTimeout} should not call callback`);
+ assert.fail(`Timer ${this._idleTimeout} should not call callback`);
}
diff --git a/benchmark/tls/convertprotocols.js b/benchmark/tls/convertprotocols.js
index 1ee2672bee7bd7..9f4969344d1bcd 100644
--- a/benchmark/tls/convertprotocols.js
+++ b/benchmark/tls/convertprotocols.js
@@ -8,14 +8,15 @@ const bench = common.createBenchmark(main, {
});
function main({ n }) {
- var i = 0;
+ const input = ['ABC', 'XYZ123', 'FOO'];
var m = {};
// First call dominates results
if (n > 1) {
- tls.convertNPNProtocols(['ABC', 'XYZ123', 'FOO'], m);
+ tls.convertNPNProtocols(input, m);
m = {};
}
bench.start();
- for (; i < n; i++) tls.convertNPNProtocols(['ABC', 'XYZ123', 'FOO'], m);
+ for (var i = 0; i < n; i++)
+ tls.convertNPNProtocols(input, m);
bench.end(n);
}
diff --git a/benchmark/tls/throughput.js b/benchmark/tls/throughput.js
index f63257c49693d6..1ca52ad9496237 100644
--- a/benchmark/tls/throughput.js
+++ b/benchmark/tls/throughput.js
@@ -40,11 +40,11 @@ function main({ dur, type, size }) {
};
server = tls.createServer(options, onConnection);
- setTimeout(done, dur * 1000);
var conn;
server.listen(common.PORT, function() {
const opt = { port: common.PORT, rejectUnauthorized: false };
conn = tls.connect(opt, function() {
+ setTimeout(done, dur * 1000);
bench.start();
conn.on('drain', write);
write();
diff --git a/benchmark/tls/tls-connect.js b/benchmark/tls/tls-connect.js
index 67f2d5f8a932e0..da0f5e08d5e6db 100644
--- a/benchmark/tls/tls-connect.js
+++ b/benchmark/tls/tls-connect.js
@@ -11,12 +11,13 @@ const bench = common.createBenchmark(main, {
var clientConn = 0;
var serverConn = 0;
-var server;
var dur;
var concurrency;
var running = true;
-function main({ dur, concurrency }) {
+function main(conf) {
+ dur = conf.dur;
+ concurrency = conf.concurrency;
const cert_dir = path.resolve(__dirname, '../../test/fixtures');
const options = {
key: fs.readFileSync(`${cert_dir}/test_key.pem`),
@@ -25,7 +26,7 @@ function main({ dur, concurrency }) {
ciphers: 'AES256-GCM-SHA384'
};
- server = tls.createServer(options, onConnection);
+ const server = tls.createServer(options, onConnection);
server.listen(common.PORT, onListening);
}
diff --git a/benchmark/url/legacy-vs-whatwg-url-get-prop.js b/benchmark/url/legacy-vs-whatwg-url-get-prop.js
index 93603c258cf1f2..2cc3ab8c75e65c 100644
--- a/benchmark/url/legacy-vs-whatwg-url-get-prop.js
+++ b/benchmark/url/legacy-vs-whatwg-url-get-prop.js
@@ -74,7 +74,7 @@ function useWHATWG(n, input) {
function main({ type, n, method }) {
const input = inputs[type];
if (!input) {
- throw new Error('Unknown input type');
+ throw new Error(`Unknown input type "${type}"`);
}
var noDead; // Avoid dead code elimination.
@@ -86,7 +86,7 @@ function main({ type, n, method }) {
noDead = useWHATWG(n, input);
break;
default:
- throw new Error('Unknown method');
+ throw new Error(`Unknown method "${method}"`);
}
assert.ok(noDead);
diff --git a/benchmark/url/legacy-vs-whatwg-url-parse.js b/benchmark/url/legacy-vs-whatwg-url-parse.js
index da42d5a189af47..2be55e17cc354b 100644
--- a/benchmark/url/legacy-vs-whatwg-url-parse.js
+++ b/benchmark/url/legacy-vs-whatwg-url-parse.js
@@ -34,7 +34,7 @@ function useWHATWG(n, input) {
function main({ type, n, method }) {
const input = inputs[type];
if (!input) {
- throw new Error('Unknown input type');
+ throw new Error(`Unknown input type "${type}"`);
}
var noDead; // Avoid dead code elimination.
@@ -46,7 +46,7 @@ function main({ type, n, method }) {
noDead = useWHATWG(n, input);
break;
default:
- throw new Error('Unknown method');
+ throw new Error(`Unknown method ${method}`);
}
assert.ok(noDead);
diff --git a/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js b/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js
index 51953ec8707374..e915ceb54f917f 100644
--- a/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js
+++ b/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js
@@ -31,7 +31,7 @@ function useWHATWG(n, input) {
function main({ type, n, method }) {
const input = inputs[type];
if (!input) {
- throw new Error('Unknown input type');
+ throw new Error(`Unknown input type "${type}"`);
}
switch (method) {
@@ -42,6 +42,6 @@ function main({ type, n, method }) {
useWHATWG(n, input);
break;
default:
- throw new Error('Unknown method');
+ throw new Error(`Unknown method ${method}`);
}
}
diff --git a/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js b/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js
index 3490782a1bf421..8fe3e546f0780d 100644
--- a/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js
+++ b/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js
@@ -33,7 +33,7 @@ function useWHATWG(n, input, prop) {
function main({ type, n, method }) {
const input = inputs[type];
if (!input) {
- throw new Error('Unknown input type');
+ throw new Error(`Unknown input type "${type}"`);
}
switch (method) {
@@ -44,6 +44,6 @@ function main({ type, n, method }) {
useWHATWG(n, input);
break;
default:
- throw new Error('Unknown method');
+ throw new Error(`Unknown method ${method}`);
}
}
diff --git a/benchmark/url/legacy-vs-whatwg-url-serialize.js b/benchmark/url/legacy-vs-whatwg-url-serialize.js
index e92b941b5d57e5..017ec4328c590b 100644
--- a/benchmark/url/legacy-vs-whatwg-url-serialize.js
+++ b/benchmark/url/legacy-vs-whatwg-url-serialize.js
@@ -36,7 +36,7 @@ function useWHATWG(n, input, prop) {
function main({ type, n, method }) {
const input = inputs[type];
if (!input) {
- throw new Error('Unknown input type');
+ throw new Error(`Unknown input type "${type}"`);
}
var noDead; // Avoid dead code elimination.
@@ -48,7 +48,7 @@ function main({ type, n, method }) {
noDead = useWHATWG(n, input);
break;
default:
- throw new Error('Unknown method');
+ throw new Error(`Unknown method ${method}`);
}
assert.ok(noDead);
diff --git a/benchmark/url/url-searchparams-iteration.js b/benchmark/url/url-searchparams-iteration.js
index 2b13992bdfcfc0..cae2ef5df61956 100644
--- a/benchmark/url/url-searchparams-iteration.js
+++ b/benchmark/url/url-searchparams-iteration.js
@@ -53,6 +53,6 @@ function main({ method, n }) {
iterator(n);
break;
default:
- throw new Error('Unknown method');
+ throw new Error(`Unknown method ${method}`);
}
}
diff --git a/benchmark/url/url-searchparams-read.js b/benchmark/url/url-searchparams-read.js
index 29235ee81e0e14..0cf66dabbc36dc 100644
--- a/benchmark/url/url-searchparams-read.js
+++ b/benchmark/url/url-searchparams-read.js
@@ -10,45 +10,14 @@ const bench = common.createBenchmark(main, {
const str = 'one=single&two=first&three=first&two=2nd&three=2nd&three=3rd';
-function get(n, param) {
- const params = new URLSearchParams(str);
-
- bench.start();
- for (var i = 0; i < n; i += 1)
- params.get(param);
- bench.end(n);
-}
-
-function getAll(n, param) {
- const params = new URLSearchParams(str);
-
- bench.start();
- for (var i = 0; i < n; i += 1)
- params.getAll(param);
- bench.end(n);
-}
-
-function has(n, param) {
+function main({ method, param, n }) {
const params = new URLSearchParams(str);
+ const fn = params[method];
+ if (!fn)
+ throw new Error(`Unknown method ${method}`);
bench.start();
for (var i = 0; i < n; i += 1)
- params.has(param);
+ fn(param);
bench.end(n);
}
-
-function main({ method, param, n }) {
- switch (method) {
- case 'get':
- get(n, param);
- break;
- case 'getAll':
- getAll(n, param);
- break;
- case 'has':
- has(n, param);
- break;
- default:
- throw new Error('Unknown method');
- }
-}
diff --git a/benchmark/url/url-searchparams-sort.js b/benchmark/url/url-searchparams-sort.js
index 524dacb6d52dc4..fe152bf823468f 100644
--- a/benchmark/url/url-searchparams-sort.js
+++ b/benchmark/url/url-searchparams-sort.js
@@ -37,9 +37,8 @@ function main({ type, n }) {
const params = new URLSearchParams();
const array = getParams(input);
- var i;
bench.start();
- for (i = 0; i < n; i++) {
+ for (var i = 0; i < n; i++) {
params[searchParams] = array.slice();
params.sort();
}
diff --git a/benchmark/util/format.js b/benchmark/util/format.js
index 5f9c4c3b594497..042b8a93ccfcf2 100644
--- a/benchmark/util/format.js
+++ b/benchmark/util/format.js
@@ -22,9 +22,7 @@ const bench = common.createBenchmark(main, {
function main({ n, type }) {
// For testing, if supplied with an empty type, default to string.
- type = type || 'string';
-
- const [first, second] = inputs[type];
+ const [first, second] = inputs[type || 'string'];
bench.start();
for (var i = 0; i < n; i++) {
diff --git a/benchmark/util/inspect-array.js b/benchmark/util/inspect-array.js
index 74332d18579865..8b3c54aeb942fe 100644
--- a/benchmark/util/inspect-array.js
+++ b/benchmark/util/inspect-array.js
@@ -18,14 +18,13 @@ function main({ n, len, type }) {
var arr = Array(len);
var i, opts;
- // For testing, if supplied with an empty type, default to denseArray.
- type = type || 'denseArray';
-
switch (type) {
case 'denseArray_showHidden':
opts = { showHidden: true };
arr = arr.fill('denseArray');
break;
+ // For testing, if supplied with an empty type, default to denseArray.
+ case '':
case 'denseArray':
arr = arr.fill('denseArray');
break;
diff --git a/benchmark/v8/get-stats.js b/benchmark/v8/get-stats.js
index 6ee742858629c2..84a0655f5db4fa 100644
--- a/benchmark/v8/get-stats.js
+++ b/benchmark/v8/get-stats.js
@@ -12,9 +12,8 @@ const bench = common.createBenchmark(main, {
});
function main({ method, n }) {
- var i = 0;
bench.start();
- for (; i < n; i++)
+ for (var i = 0; i < n; i++)
v8[method]();
bench.end(n);
}
diff --git a/benchmark/vm/run-in-context.js b/benchmark/vm/run-in-context.js
index da8f56a6e0153b..9b57067a19c9ac 100644
--- a/benchmark/vm/run-in-context.js
+++ b/benchmark/vm/run-in-context.js
@@ -17,12 +17,10 @@ function main({ n, breakOnSigint, withSigintListener }) {
if (withSigintListener)
process.on('SIGINT', () => {});
- var i = 0;
-
const contextifiedSandbox = vm.createContext();
bench.start();
- for (; i < n; i++)
+ for (var i = 0; i < n; i++)
vm.runInContext('0', contextifiedSandbox, options);
bench.end(n);
}
diff --git a/benchmark/vm/run-in-this-context.js b/benchmark/vm/run-in-this-context.js
index 33fd3a34d81f8f..0754287376d58c 100644
--- a/benchmark/vm/run-in-this-context.js
+++ b/benchmark/vm/run-in-this-context.js
@@ -17,10 +17,8 @@ function main({ n, breakOnSigint, withSigintListener }) {
if (withSigintListener)
process.on('SIGINT', () => {});
- var i = 0;
-
bench.start();
- for (; i < n; i++)
+ for (var i = 0; i < n; i++)
vm.runInThisContext('0', options);
bench.end(n);
}
diff --git a/common.gypi b/common.gypi
index 0ee48812415799..a08e7f487f3b3e 100644
--- a/common.gypi
+++ b/common.gypi
@@ -27,7 +27,7 @@
# 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.18',
+ 'v8_embedder_string': '-node.20',
# Enable disassembler for `--print-code` v8 options
'v8_enable_disassembler': 1,
@@ -288,7 +288,7 @@
],
}],
[ 'OS in "linux freebsd openbsd solaris aix"', {
- 'cflags': [ '-pthread', ],
+ 'cflags': [ '-pthread' ],
'ldflags': [ '-pthread' ],
}],
[ 'OS in "linux freebsd openbsd solaris android aix cloudabi"', {
@@ -301,6 +301,7 @@
'standalone_static_library': 1,
}],
['OS=="openbsd"', {
+ 'cflags': [ '-I/usr/local/include' ],
'ldflags': [ '-Wl,-z,wxneeded' ],
}],
],
diff --git a/configure b/configure
index fc1be60c97496c..d999cfc47d87fd 100755
--- a/configure
+++ b/configure
@@ -61,7 +61,7 @@ parser = optparse.OptionParser()
valid_os = ('win', 'mac', 'solaris', 'freebsd', 'openbsd', 'linux',
'android', 'aix', 'cloudabi')
valid_arch = ('arm', 'arm64', 'ia32', 'mips', 'mipsel', 'mips64el', 'ppc',
- 'ppc64', 'x32','x64', 'x86', 's390', 's390x')
+ 'ppc64', 'x32','x64', 'x86', 'x86_64', 's390', 's390x')
valid_arm_float_abi = ('soft', 'softfp', 'hard')
valid_arm_fpu = ('vfp', 'vfpv3', 'vfpv3-d16', 'neon')
valid_mips_arch = ('loongson', 'r1', 'r2', 'r6', 'rx')
@@ -861,6 +861,9 @@ def configure_node(o):
# the Makefile resets this to x86 afterward
if target_arch == 'x86':
target_arch = 'ia32'
+ # x86_64 is common across linuxes, allow it as an alias for x64
+ if target_arch == 'x86_64':
+ target_arch = 'x64'
o['variables']['host_arch'] = host_arch
o['variables']['target_arch'] = target_arch
o['variables']['node_byteorder'] = sys.byteorder
@@ -1125,8 +1128,8 @@ def glob_to_var(dir_base, dir_sub, patch_dir):
def configure_intl(o):
icus = [
{
- 'url': 'https://ssl.icu-project.org/files/icu4c/60.1/icu4c-60_1-src.zip',
- 'md5': 'e6cb990ac2a3161d31a3def8435f80cb',
+ 'url': 'https://ssl.icu-project.org/files/icu4c/60.2/icu4c-60_2-src.zip',
+ 'md5': '115908818fd0324530b2acb1b029738d',
},
]
def icu_download(path):
diff --git a/deps/icu-small/source/common/rbbi_cache.h b/deps/icu-small/source/common/rbbi_cache.h
index b8a18d81deb1d9..8dc7320db90a9e 100644
--- a/deps/icu-small/source/common/rbbi_cache.h
+++ b/deps/icu-small/source/common/rbbi_cache.h
@@ -121,7 +121,7 @@ class RuleBasedBreakIterator::BreakCache: public UMemory {
* If the requested position is a break boundary, leave the iteration
* position on it.
* If the requested position is not a boundary, leave the iteration
- * position on the preceding boundary and include both the the
+ * position on the preceding boundary and include both the
* preceding and following boundaries in the cache.
* Additional boundaries, either preceding or following, may be added
* to the cache as a side effect.
diff --git a/deps/icu-small/source/common/rbbicst.pl b/deps/icu-small/source/common/rbbicst.pl
old mode 100644
new mode 100755
diff --git a/deps/icu-small/source/common/ucnv_u8.cpp b/deps/icu-small/source/common/ucnv_u8.cpp
index 866cf81659486b..c7ef87fd500c62 100644
--- a/deps/icu-small/source/common/ucnv_u8.cpp
+++ b/deps/icu-small/source/common/ucnv_u8.cpp
@@ -28,6 +28,7 @@
#include "unicode/utf.h"
#include "unicode/utf8.h"
#include "unicode/utf16.h"
+#include "uassert.h"
#include "ucnv_bld.h"
#include "ucnv_cnv.h"
#include "cmemory.h"
@@ -694,7 +695,9 @@ ucnv_UTF8FromUTF8(UConverterFromUnicodeArgs *pFromUArgs,
// Use a single counter for source and target, counting the minimum of
// the source length and the target capacity.
// Let the standard converter handle edge cases.
+ const uint8_t *limit=sourceLimit;
if(count>targetCapacity) {
+ limit-=(count-targetCapacity);
count=targetCapacity;
}
@@ -707,11 +710,11 @@ ucnv_UTF8FromUTF8(UConverterFromUnicodeArgs *pFromUArgs,
// sequence from the previous buffer.
int32_t length=count-toULimit;
if(length>0) {
- uint8_t b1=*(sourceLimit-1);
+ uint8_t b1=*(limit-1);
if(U8_IS_SINGLE(b1)) {
// common ASCII character
} else if(U8_IS_TRAIL(b1) && length>=2) {
- uint8_t b2=*(sourceLimit-2);
+ uint8_t b2=*(limit-2);
if(0xe0<=b2 && b2<0xf0 && U8_IS_VALID_LEAD3_AND_T1(b2, b1)) {
// truncated 3-byte sequence
count-=2;
@@ -811,7 +814,7 @@ ucnv_UTF8FromUTF8(UConverterFromUnicodeArgs *pFromUArgs,
}
/* copy the legal byte sequence to the target */
- {
+ if(count>=toULength) {
int8_t i;
for(i=0; isource=(char *)source;
+ pFromUArgs->target=(char *)target;
+ *pErrorCode=U_USING_DEFAULT_WARNING;
+ return;
}
}
}
+ U_ASSERT(count>=0);
if(U_SUCCESS(*pErrorCode) && sourcetargetLimit) {
diff --git a/deps/icu-small/source/common/unicode/brkiter.h b/deps/icu-small/source/common/unicode/brkiter.h
index 9c1ac7531bc60d..c64bb712222c63 100644
--- a/deps/icu-small/source/common/unicode/brkiter.h
+++ b/deps/icu-small/source/common/unicode/brkiter.h
@@ -292,7 +292,7 @@ class U_COMMON_API BreakIterator : public UObject {
* does nothing. Negative values move to previous boundaries
* and positive values move to later boundaries.
* @return The new iterator position, or
- * DONE if there are fewer than |n| boundaries in the specfied direction.
+ * DONE if there are fewer than |n| boundaries in the specified direction.
* @stable ICU 2.0
*/
virtual int32_t next(int32_t n) = 0;
diff --git a/deps/icu-small/source/common/unicode/ucnv.h b/deps/icu-small/source/common/unicode/ucnv.h
index 86e3b8447449d9..05d0050f4a2fc9 100644
--- a/deps/icu-small/source/common/unicode/ucnv.h
+++ b/deps/icu-small/source/common/unicode/ucnv.h
@@ -29,7 +29,7 @@
* converter, you can get its properties, set options, convert your data and
* close the converter.
*
- * Since many software programs recogize different converter names for
+ * Since many software programs recognize different converter names for
* different types of converters, there are other functions in this API to
* iterate over the converter aliases. The functions {@link ucnv_getAvailableName() },
* {@link ucnv_getAlias() } and {@link ucnv_getStandardName() } are some of the
@@ -184,7 +184,7 @@ typedef enum {
/**
* Function pointer for error callback in the codepage to unicode direction.
- * Called when an error has occured in conversion to unicode, or on open/close of the callback (see reason).
+ * Called when an error has occurred in conversion to unicode, or on open/close of the callback (see reason).
* @param context Pointer to the callback's private data
* @param args Information about the conversion in progress
* @param codeUnits Points to 'length' bytes of the concerned codepage sequence
@@ -452,7 +452,7 @@ ucnv_openU(const UChar *name,
* @param platform the platform in which the codepage number exists
* @param err error status U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR
* @return the created Unicode converter object, or NULL if an error
- * occured.
+ * occurred.
* @see ucnv_open
* @see ucnv_openU
* @see ucnv_close
@@ -596,7 +596,7 @@ U_NAMESPACE_END
* stateful, then subChars will be an empty string.
*
* @param converter the Unicode converter
- * @param subChars the subsitution characters
+ * @param subChars the substitution characters
* @param len on input the capacity of subChars, on output the number
* of bytes copied to it
* @param err the outgoing error status code.
@@ -832,7 +832,7 @@ ucnv_getMinCharSize(const UConverter *converter);
* name will be filled in.
*
* @param converter the Unicode converter.
- * @param displayLocale is the specific Locale we want to localised for
+ * @param displayLocale is the specific Locale we want to localized for
* @param displayName user provided buffer to be filled in
* @param displayNameCapacity size of displayName Buffer
* @param err error status code
@@ -877,7 +877,7 @@ ucnv_getName(const UConverter *converter, UErrorCode *err);
*
* @param converter the Unicode converter
* @param err the error status code.
- * @return If any error occurrs, -1 will be returned otherwise, the codepage number
+ * @return If any error occurs, -1 will be returned otherwise, the codepage number
* will be returned
* @see ucnv_openCCSID
* @see ucnv_getPlatform
diff --git a/deps/icu-small/source/common/unicode/utext.h b/deps/icu-small/source/common/unicode/utext.h
index 55709d403a6d02..7eea1da240c1d5 100644
--- a/deps/icu-small/source/common/unicode/utext.h
+++ b/deps/icu-small/source/common/unicode/utext.h
@@ -389,7 +389,7 @@ utext_equals(const UText *a, const UText *b);
/*****************************************************************************
*
- * Functions to work with the text represeted by a UText wrapper
+ * Functions to work with the text represented by a UText wrapper
*
*****************************************************************************/
@@ -433,7 +433,7 @@ utext_isLengthExpensive(const UText *ut);
*
* The iteration position will be set to the start of the returned code point.
*
- * This function is roughly equivalent to the the sequence
+ * This function is roughly equivalent to the sequence
* utext_setNativeIndex(index);
* utext_current32();
* (There is a subtle difference if the index is out of bounds by being less than zero -
@@ -592,7 +592,7 @@ U_STABLE void U_EXPORT2
utext_setNativeIndex(UText *ut, int64_t nativeIndex);
/**
- * Move the iterator postion by delta code points. The number of code points
+ * Move the iterator position by delta code points. The number of code points
* is a signed number; a negative delta will move the iterator backwards,
* towards the start of the text.
*
@@ -611,7 +611,7 @@ U_STABLE UBool U_EXPORT2
utext_moveIndex32(UText *ut, int32_t delta);
/**
- * Get the native index of the character preceeding the current position.
+ * Get the native index of the character preceding the current position.
* If the iteration position is already at the start of the text, zero
* is returned.
* The value returned is the same as that obtained from the following sequence,
@@ -628,7 +628,7 @@ utext_moveIndex32(UText *ut, int32_t delta);
* native index of the character most recently returned from utext_next().
*
* @param ut the text to be accessed
- * @return the native index of the character preceeding the current index position,
+ * @return the native index of the character preceding the current index position,
* or zero if the current position is at the start of the text.
* @stable ICU 3.6
*/
@@ -1054,7 +1054,7 @@ UTextAccess(UText *ut, int64_t nativeIndex, UBool forward);
* be NUL-terminated if there is sufficient space in the destination buffer.
*
* @param ut the UText from which to extract data.
- * @param nativeStart the native index of the first characer to extract.
+ * @param nativeStart the native index of the first character to extract.
* @param nativeLimit the native string index of the position following the last
* character to extract.
* @param dest the UChar (UTF-16) buffer into which the extracted text is placed
@@ -1211,7 +1211,7 @@ UTextClose(UText *ut);
struct UTextFuncs {
/**
* (public) Function table size, sizeof(UTextFuncs)
- * Intended for use should the table grow to accomodate added
+ * Intended for use should the table grow to accommodate added
* functions in the future, to allow tests for older format
* function tables that do not contain the extensions.
*
@@ -1345,7 +1345,7 @@ typedef struct UTextFuncs UTextFuncs;
struct UText {
/**
* (private) Magic. Used to help detect when UText functions are handed
- * invalid or unitialized UText structs.
+ * invalid or uninitialized UText structs.
* utext_openXYZ() functions take an initialized,
* but not necessarily open, UText struct as an
* optional fill-in parameter. This magic field
@@ -1367,7 +1367,7 @@ struct UText {
/**
- * Text provider properties. This set of flags is maintainted by the
+ * Text provider properties. This set of flags is maintained by the
* text provider implementation.
* @stable ICU 3.4
*/
diff --git a/deps/icu-small/source/common/unicode/uvernum.h b/deps/icu-small/source/common/unicode/uvernum.h
index ce7dec15535c7e..d905a0f50d1d29 100644
--- a/deps/icu-small/source/common/unicode/uvernum.h
+++ b/deps/icu-small/source/common/unicode/uvernum.h
@@ -64,7 +64,7 @@
* This value will change in the subsequent releases of ICU
* @stable ICU 2.6
*/
-#define U_ICU_VERSION_MINOR_NUM 1
+#define U_ICU_VERSION_MINOR_NUM 2
/** The current ICU patchlevel version as an integer.
* This value will change in the subsequent releases of ICU
@@ -119,7 +119,7 @@
* This value will change in the subsequent releases of ICU
* @stable ICU 2.4
*/
-#define U_ICU_VERSION "60.1"
+#define U_ICU_VERSION "60.2"
/** The current ICU library major/minor version as a string without dots, for library name suffixes.
* This value will change in the subsequent releases of ICU
@@ -131,7 +131,7 @@
/** Data version in ICU4C.
* @internal ICU 4.4 Internal Use Only
**/
-#define U_ICU_DATA_VERSION "60.1"
+#define U_ICU_DATA_VERSION "60.2"
#endif /* U_HIDE_INTERNAL_API */
/*===========================================================================
diff --git a/deps/icu-small/source/data/in/icudt60l.dat b/deps/icu-small/source/data/in/icudt60l.dat
index 2e04376ae8bc7d..c81ffccfa9ff97 100644
Binary files a/deps/icu-small/source/data/in/icudt60l.dat and b/deps/icu-small/source/data/in/icudt60l.dat differ
diff --git a/deps/icu-small/source/i18n/calendar.cpp b/deps/icu-small/source/i18n/calendar.cpp
index 426bd7904cbd84..7ccaa43b82b1e7 100644
--- a/deps/icu-small/source/i18n/calendar.cpp
+++ b/deps/icu-small/source/i18n/calendar.cpp
@@ -708,6 +708,8 @@ fZone(NULL),
fRepeatedWallTime(UCAL_WALLTIME_LAST),
fSkippedWallTime(UCAL_WALLTIME_LAST)
{
+ validLocale[0] = 0;
+ actualLocale[0] = 0;
clear();
if (U_FAILURE(success)) {
return;
@@ -734,6 +736,8 @@ fZone(NULL),
fRepeatedWallTime(UCAL_WALLTIME_LAST),
fSkippedWallTime(UCAL_WALLTIME_LAST)
{
+ validLocale[0] = 0;
+ actualLocale[0] = 0;
if (U_FAILURE(success)) {
return;
}
@@ -766,6 +770,8 @@ fZone(NULL),
fRepeatedWallTime(UCAL_WALLTIME_LAST),
fSkippedWallTime(UCAL_WALLTIME_LAST)
{
+ validLocale[0] = 0;
+ actualLocale[0] = 0;
if (U_FAILURE(success)) {
return;
}
@@ -822,8 +828,10 @@ Calendar::operator=(const Calendar &right)
fWeekendCease = right.fWeekendCease;
fWeekendCeaseMillis = right.fWeekendCeaseMillis;
fNextStamp = right.fNextStamp;
- uprv_strcpy(validLocale, right.validLocale);
- uprv_strcpy(actualLocale, right.actualLocale);
+ uprv_strncpy(validLocale, right.validLocale, sizeof(validLocale));
+ uprv_strncpy(actualLocale, right.actualLocale, sizeof(actualLocale));
+ validLocale[sizeof(validLocale)-1] = 0;
+ actualLocale[sizeof(validLocale)-1] = 0;
}
return *this;
diff --git a/deps/icu-small/source/i18n/regexcst.pl b/deps/icu-small/source/i18n/regexcst.pl
old mode 100644
new mode 100755
diff --git a/deps/icu-small/source/i18n/unicode/selfmt.h b/deps/icu-small/source/i18n/unicode/selfmt.h
old mode 100644
new mode 100755
diff --git a/deps/icu-small/source/tools/genrb/genrb.cpp b/deps/icu-small/source/tools/genrb/genrb.cpp
index 68870bd90a175d..c4fc462066a099 100644
--- a/deps/icu-small/source/tools/genrb/genrb.cpp
+++ b/deps/icu-small/source/tools/genrb/genrb.cpp
@@ -652,7 +652,7 @@ processFile(const char *filename, const char *cp,
goto finish;
}
if (ucbuf == NULL || U_FAILURE(status)) {
- fprintf(stderr, "An error occured processing file %s. Error: %s\n",
+ fprintf(stderr, "An error occurred processing file %s. Error: %s\n",
openFileName == NULL ? filename : openFileName, u_errorName(status));
goto finish;
}
diff --git a/deps/icu-small/source/tools/genrb/parse.cpp b/deps/icu-small/source/tools/genrb/parse.cpp
index f003aa3abfab89..ddfb082afe63f4 100644
--- a/deps/icu-small/source/tools/genrb/parse.cpp
+++ b/deps/icu-small/source/tools/genrb/parse.cpp
@@ -362,7 +362,7 @@ parseUCARules(ParseState* state, char *tag, uint32_t startline, const struct USt
ucbuf = ucbuf_open(filename, &cp, getShowWarning(),FALSE, status);
if (U_FAILURE(*status)) {
- error(line, "An error occured while opening the input file %s\n", filename);
+ error(line, "An error occurred while opening the input file %s\n", filename);
return NULL;
}
@@ -500,7 +500,7 @@ parseTransliterator(ParseState* state, char *tag, uint32_t startline, const stru
ucbuf = ucbuf_open(filename, &cp, getShowWarning(),FALSE, status);
if (U_FAILURE(*status)) {
- error(line, "An error occured while opening the input file %s\n", filename);
+ error(line, "An error occurred while opening the input file %s\n", filename);
return NULL;
}
@@ -758,7 +758,7 @@ GenrbImporter::getRules(
return;
}
if (ucbuf.isNull() || U_FAILURE(errorCode)) {
- fprintf(stderr, "An error occured processing file %s. Error: %s\n", openFileName.data(), u_errorName(errorCode));
+ fprintf(stderr, "An error occurred processing file %s. Error: %s\n", openFileName.data(), u_errorName(errorCode));
return;
}
diff --git a/deps/node-inspect/CHANGELOG.md b/deps/node-inspect/CHANGELOG.md
index 41ed928e781ff6..0db3a7842eb15d 100644
--- a/deps/node-inspect/CHANGELOG.md
+++ b/deps/node-inspect/CHANGELOG.md
@@ -1,3 +1,12 @@
+### 1.11.3
+
+* [`93caa0f`](https://github.com/nodejs/node-inspect/commit/93caa0f5267c7ab452b258d3b03329a0bb5ac7f7) **docs:** Add missing oc in protocol
+* [`2d87cbe`](https://github.com/nodejs/node-inspect/commit/2d87cbe76aa968dfc1ac69d9571af1be81abd8e0) **fix:** Make --inspect-port=0 work
+* [`ebfd02e`](https://github.com/nodejs/node-inspect/commit/ebfd02ece9b642586023f7791da71defeb13d746) **chore:** Bump tap to 10.7
+* [`c07adb1`](https://github.com/nodejs/node-inspect/commit/c07adb17b164c1cf3da8d38659ea9f5d7ff42e9c) **test:** Use useful break location
+* [`94f0bf9`](https://github.com/nodejs/node-inspect/commit/94f0bf97d24c376baf3ecced2088d81715a73464) **fix:** Fix `takeHeapSnapshot()` truncation bug
+
+
### 1.11.2
* [`42e0cd1`](https://github.com/nodejs/node-inspect/commit/42e0cd111d89ed09faba1c0ec45089b0b44de011) **fix:** look for generic hint text
diff --git a/deps/node-inspect/README.md b/deps/node-inspect/README.md
index ecd939b3ea26a8..b52cc188a62f5b 100644
--- a/deps/node-inspect/README.md
+++ b/deps/node-inspect/README.md
@@ -10,7 +10,7 @@ node has two options:
1. `node --debug `: Start `file` with remote debugging enabled.
2. `node debug `: Start an interactive CLI debugger for ``.
-But for the Chrome inspector protol,
+But for the Chrome inspector protocol,
there's only one: `node --inspect `.
This project tries to provide the missing second option
diff --git a/deps/node-inspect/lib/_inspect.js b/deps/node-inspect/lib/_inspect.js
index 26912274cdaec4..d846efbe6a4a52 100644
--- a/deps/node-inspect/lib/_inspect.js
+++ b/deps/node-inspect/lib/_inspect.js
@@ -42,18 +42,9 @@ const [ InspectClient, createRepl ] =
const debuglog = util.debuglog('inspect');
-const DEBUG_PORT_PATTERN = /^--(?:debug|inspect)(?:-port|-brk)?=(\d{1,5})$/;
-function getDefaultPort() {
- for (const arg of process.execArgv) {
- const match = arg.match(DEBUG_PORT_PATTERN);
- if (match) {
- return +match[1];
- }
- }
- return 9229;
-}
-
function portIsFree(host, port, timeout = 2000) {
+ if (port === 0) return Promise.resolve(); // Binding to a random port.
+
const retryDelay = 150;
let didTimeOut = false;
@@ -110,9 +101,11 @@ function runScript(script, scriptArgs, inspectHost, inspectPort, childPrint) {
let output = '';
function waitForListenHint(text) {
output += text;
- if (/Debugger listening on/.test(output)) {
+ if (/Debugger listening on ws:\/\/\[?(.+?)\]?:(\d+)\//.test(output)) {
+ const host = RegExp.$1;
+ const port = Number.parseInt(RegExp.$2);
child.stderr.removeListener('data', waitForListenHint);
- resolve(child);
+ resolve([child, port, host]);
}
}
@@ -160,10 +153,11 @@ class NodeInspector {
options.port,
this.childPrint.bind(this));
} else {
- this._runScript = () => Promise.resolve(null);
+ this._runScript =
+ () => Promise.resolve([null, options.port, options.host]);
}
- this.client = new InspectClient(options.port, options.host);
+ this.client = new InspectClient();
this.domainNames = ['Debugger', 'HeapProfiler', 'Profiler', 'Runtime'];
this.domainNames.forEach((domain) => {
@@ -223,9 +217,8 @@ class NodeInspector {
run() {
this.killChild();
- const { host, port } = this.options;
- return this._runScript().then((child) => {
+ return this._runScript().then(([child, port, host]) => {
this.child = child;
let connectionAttempts = 0;
@@ -233,7 +226,7 @@ class NodeInspector {
++connectionAttempts;
debuglog('connection attempt #%d', connectionAttempts);
this.stdout.write('.');
- return this.client.connect()
+ return this.client.connect(port, host)
.then(() => {
debuglog('connection established');
this.stdout.write(' ok');
@@ -288,7 +281,7 @@ class NodeInspector {
function parseArgv([target, ...args]) {
let host = '127.0.0.1';
- let port = getDefaultPort();
+ let port = 9229;
let isRemote = false;
let script = target;
let scriptArgs = args;
diff --git a/deps/node-inspect/lib/internal/inspect_client.js b/deps/node-inspect/lib/internal/inspect_client.js
index c247e2add87706..9b8529de21aae2 100644
--- a/deps/node-inspect/lib/internal/inspect_client.js
+++ b/deps/node-inspect/lib/internal/inspect_client.js
@@ -164,12 +164,12 @@ function decodeFrameHybi17(data) {
}
class Client extends EventEmitter {
- constructor(port, host) {
+ constructor() {
super();
this.handleChunk = this._handleChunk.bind(this);
- this._port = port;
- this._host = host;
+ this._port = undefined;
+ this._host = undefined;
this.reset();
}
@@ -284,7 +284,9 @@ class Client extends EventEmitter {
});
}
- connect() {
+ connect(port, host) {
+ this._port = port;
+ this._host = host;
return this._discoverWebsocketPath()
.then((urlPath) => this._connectWebsocket(urlPath));
}
diff --git a/deps/node-inspect/lib/internal/inspect_repl.js b/deps/node-inspect/lib/internal/inspect_repl.js
index 937c1843d3a3ee..38fe4684cf6d71 100644
--- a/deps/node-inspect/lib/internal/inspect_repl.js
+++ b/deps/node-inspect/lib/internal/inspect_repl.js
@@ -900,10 +900,8 @@ function createRepl(inspector) {
return new Promise((resolve, reject) => {
const absoluteFile = Path.resolve(filename);
const writer = FS.createWriteStream(absoluteFile);
- let totalSize;
let sizeWritten = 0;
function onProgress({ done, total, finished }) {
- totalSize = total;
if (finished) {
print('Heap snaphost prepared.');
} else {
@@ -913,13 +911,18 @@ function createRepl(inspector) {
function onChunk({ chunk }) {
sizeWritten += chunk.length;
writer.write(chunk);
- print(`Writing snapshot: ${sizeWritten}/${totalSize}`, true);
- if (sizeWritten >= totalSize) {
- writer.end();
+ print(`Writing snapshot: ${sizeWritten}`, true);
+ }
+ function onResolve() {
+ writer.end(() => {
teardown();
print(`Wrote snapshot: ${absoluteFile}`);
resolve();
- }
+ });
+ }
+ function onReject(error) {
+ teardown();
+ reject(error);
}
function teardown() {
HeapProfiler.removeListener(
@@ -932,10 +935,7 @@ function createRepl(inspector) {
print('Heap snapshot: 0/0', true);
HeapProfiler.takeHeapSnapshot({ reportProgress: true })
- .then(null, (error) => {
- teardown();
- reject(error);
- });
+ .then(onResolve, onReject);
});
},
diff --git a/deps/node-inspect/package.json b/deps/node-inspect/package.json
index 070abfa8fe51be..d25376b5d4bb96 100644
--- a/deps/node-inspect/package.json
+++ b/deps/node-inspect/package.json
@@ -1,6 +1,6 @@
{
"name": "node-inspect",
- "version": "1.11.2",
+ "version": "1.11.3",
"description": "Node Inspect",
"license": "MIT",
"main": "lib/_inspect.js",
@@ -29,7 +29,7 @@
"devDependencies": {
"eslint": "^3.10.2",
"nlm": "^3.0.0",
- "tap": "^7.1.2"
+ "tap": "^10.7.0"
},
"author": {
"name": "Jan Krems",
diff --git a/deps/node-inspect/test/cli/break.test.js b/deps/node-inspect/test/cli/break.test.js
index 59b12cde388c01..ce8c8d6d7d99bd 100644
--- a/deps/node-inspect/test/cli/break.test.js
+++ b/deps/node-inspect/test/cli/break.test.js
@@ -134,7 +134,7 @@ test('sb before loading file', (t) => {
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
- .then(() => cli.command('sb("other.js", 3)'))
+ .then(() => cli.command('sb("other.js", 2)'))
.then(() => {
t.match(
cli.output,
@@ -145,7 +145,7 @@ test('sb before loading file', (t) => {
.then(() => {
t.match(
cli.output,
- `break in ${otherScript}:3`,
+ `break in ${otherScript}:2`,
'found breakpoint in file that was not loaded yet');
})
.then(() => cli.quit())
diff --git a/deps/node-inspect/test/cli/heap-profiler.test.js b/deps/node-inspect/test/cli/heap-profiler.test.js
new file mode 100644
index 00000000000000..ebd734e03cb06d
--- /dev/null
+++ b/deps/node-inspect/test/cli/heap-profiler.test.js
@@ -0,0 +1,34 @@
+'use strict';
+const { test } = require('tap');
+const { readFileSync, unlinkSync } = require('fs');
+
+const startCLI = require('./start-cli');
+const filename = 'node.heapsnapshot';
+
+function cleanup() {
+ try {
+ unlinkSync(filename);
+ } catch (_) {
+ // Ignore.
+ }
+}
+
+cleanup();
+
+test('Heap profiler take snapshot', (t) => {
+ const cli = startCLI(['examples/empty.js']);
+
+ function onFatal(error) {
+ cli.quit();
+ throw error;
+ }
+
+ // Check that the snapshot is valid JSON.
+ return cli.waitForInitialBreak()
+ .then(() => cli.waitForPrompt())
+ .then(() => cli.command('takeHeapSnapshot()'))
+ .then(() => JSON.parse(readFileSync(filename, 'utf8')))
+ .then(() => cleanup())
+ .then(() => cli.quit())
+ .then(null, onFatal);
+});
diff --git a/deps/node-inspect/test/cli/launch.test.js b/deps/node-inspect/test/cli/launch.test.js
index f7efc6eb3f2139..8808d47a08b900 100644
--- a/deps/node-inspect/test/cli/launch.test.js
+++ b/deps/node-inspect/test/cli/launch.test.js
@@ -26,6 +26,46 @@ test('custom port', (t) => {
});
});
+test('random port', (t) => {
+ const script = Path.join('examples', 'three-lines.js');
+
+ const cli = startCLI(['--port=0', script]);
+
+ return cli.waitForInitialBreak()
+ .then(() => cli.waitForPrompt())
+ .then(() => {
+ t.match(cli.output, 'debug>', 'prints a prompt');
+ t.match(
+ cli.output,
+ /< Debugger listening on /,
+ 'forwards child output');
+ })
+ .then(() => cli.quit())
+ .then((code) => {
+ t.equal(code, 0, 'exits with success');
+ });
+});
+
+test('random port with --inspect-port=0', (t) => {
+ const script = Path.join('examples', 'three-lines.js');
+
+ const cli = startCLI([script], ['--inspect-port=0']);
+
+ return cli.waitForInitialBreak()
+ .then(() => cli.waitForPrompt())
+ .then(() => {
+ t.match(cli.output, 'debug>', 'prints a prompt');
+ t.match(
+ cli.output,
+ /< Debugger listening on /,
+ 'forwards child output');
+ })
+ .then(() => cli.quit())
+ .then((code) => {
+ t.equal(code, 0, 'exits with success');
+ });
+});
+
test('examples/three-lines.js', (t) => {
const script = Path.join('examples', 'three-lines.js');
const cli = startCLI([script]);
diff --git a/deps/node-inspect/test/cli/start-cli.js b/deps/node-inspect/test/cli/start-cli.js
index ae904308e02270..b086dcd8ba218d 100644
--- a/deps/node-inspect/test/cli/start-cli.js
+++ b/deps/node-inspect/test/cli/start-cli.js
@@ -16,8 +16,8 @@ const BREAK_MESSAGE = new RegExp('(?:' + [
'exception', 'other', 'promiseRejection',
].join('|') + ') in', 'i');
-function startCLI(args) {
- const child = spawn(process.execPath, [CLI, ...args]);
+function startCLI(args, flags = []) {
+ const child = spawn(process.execPath, [...flags, CLI, ...args]);
let isFirstStdoutChunk = true;
const outputBuffer = [];
diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h
index b183d4342fcbcf..7393dc6cbcc13a 100644
--- a/deps/v8/include/v8.h
+++ b/deps/v8/include/v8.h
@@ -104,6 +104,7 @@ class String;
class StringObject;
class Symbol;
class SymbolObject;
+class PrimitiveArray;
class Private;
class Uint32;
class Utils;
@@ -978,6 +979,48 @@ class V8_EXPORT Data {
Data();
};
+/**
+ * This is an unfinished experimental feature, and is only exposed
+ * here for internal testing purposes. DO NOT USE.
+ *
+ * A container type that holds relevant metadata for module loading.
+ *
+ * This is passed back to the embedder as part of
+ * HostImportDynamicallyCallback for module loading.
+ */
+class V8_EXPORT ScriptOrModule {
+ public:
+ /**
+ * The name that was passed by the embedder as ResourceName to the
+ * ScriptOrigin. This can be either a v8::String or v8::Undefined.
+ */
+ Local GetResourceName();
+
+ /**
+ * The options that were passed by the embedder as HostDefinedOptions to
+ * the ScriptOrigin.
+ */
+ Local GetHostDefinedOptions();
+};
+
+/**
+ * This is an unfinished experimental feature, and is only exposed
+ * here for internal testing purposes. DO NOT USE.
+ *
+ * An array to hold Primitive values. This is used by the embedder to
+ * pass host defined options to the ScriptOptions during compilation.
+ *
+ * This is passed back to the embedder as part of
+ * HostImportDynamicallyCallback for module loading.
+ *
+ */
+class V8_EXPORT PrimitiveArray {
+ public:
+ static Local New(Isolate* isolate, int length);
+ int Length() const;
+ void Set(int index, Local item);
+ Local Get(int index);
+};
/**
* The optional attributes of ScriptOrigin.
@@ -1027,13 +1070,17 @@ class ScriptOrigin {
Local source_map_url = Local(),
Local resource_is_opaque = Local(),
Local is_wasm = Local(),
- Local is_module = Local());
+ Local is_module = Local() /*,
+ // Backed out for ABI compatibility with V8 6.2
+ Local host_defined_options = Local() */);
V8_INLINE Local ResourceName() const;
V8_INLINE Local ResourceLineOffset() const;
V8_INLINE Local ResourceColumnOffset() const;
V8_INLINE Local ScriptID() const;
V8_INLINE Local SourceMapUrl() const;
+ // Backed out for ABI compatibility with V8 6.2
+ // V8_INLINE Local HostDefinedOptions() const;
V8_INLINE ScriptOriginOptions Options() const { return options_; }
private:
@@ -1043,6 +1090,8 @@ class ScriptOrigin {
ScriptOriginOptions options_;
Local script_id_;
Local source_map_url_;
+ // Backed out for ABI compatibility with V8 6.2
+ // Local host_defined_options_;
};
/**
@@ -1289,6 +1338,7 @@ class V8_EXPORT ScriptCompiler {
Local resource_column_offset;
ScriptOriginOptions resource_options;
Local source_map_url;
+ // Local host_defined_options;
// Cached data from previous compilation (if a kConsume*Cache flag is
// set), or hold newly generated cache data (kProduce*Cache flags) are
@@ -6209,8 +6259,8 @@ typedef void (*DeprecatedCallCompletedCallback)();
* embedder to load a module. This is used as part of the dynamic
* import syntax.
*
- * The referrer is the name of the file which calls the dynamic
- * import. The referrer can be used to resolve the module location.
+ * The referrer contains metadata about the script/module that calls
+ * import.
*
* The specifier is the name of the module that should be imported.
*
@@ -6225,7 +6275,8 @@ typedef void (*DeprecatedCallCompletedCallback)();
* that exception by returning an empty MaybeLocal.
*/
typedef MaybeLocal (*HostImportModuleDynamicallyCallback)(
- Local context, Local referrer, Local specifier);
+ Local context, Local referrer,
+ Local specifier);
/**
* PromiseHook with type kInit is called when a new promise is
@@ -9545,7 +9596,9 @@ ScriptOrigin::ScriptOrigin(Local resource_name,
Local script_id,
Local source_map_url,
Local resource_is_opaque,
- Local is_wasm, Local is_module)
+ Local is_wasm, Local is_module /*,
+ // Backed out for ABI compatibility with V8 6.2
+ Local host_defined_options */)
: resource_name_(resource_name),
resource_line_offset_(resource_line_offset),
resource_column_offset_(resource_column_offset),
@@ -9555,10 +9608,16 @@ ScriptOrigin::ScriptOrigin(Local resource_name,
!is_wasm.IsEmpty() && is_wasm->IsTrue(),
!is_module.IsEmpty() && is_module->IsTrue()),
script_id_(script_id),
- source_map_url_(source_map_url) {}
+ source_map_url_(source_map_url) /*,
+ // Backed out for ABI compatibility with V8 6.2
+ host_defined_options_(host_defined_options) */ {}
Local ScriptOrigin::ResourceName() const { return resource_name_; }
+// Backed out for ABI compatibility with V8 6.2
+// Local ScriptOrigin::HostDefinedOptions() const {
+// return host_defined_options_;
+// }
Local ScriptOrigin::ResourceLineOffset() const {
return resource_line_offset_;
@@ -9575,7 +9634,6 @@ Local ScriptOrigin::ScriptID() const { return script_id_; }
Local ScriptOrigin::SourceMapUrl() const { return source_map_url_; }
-
ScriptCompiler::Source::Source(Local string, const ScriptOrigin& origin,
CachedData* data)
: source_string(string),
@@ -9584,9 +9642,10 @@ ScriptCompiler::Source::Source(Local string, const ScriptOrigin& origin,
resource_column_offset(origin.ResourceColumnOffset()),
resource_options(origin.Options()),
source_map_url(origin.SourceMapUrl()),
+ // Backed out for ABI compatibility with V8 6.2
+ // host_defined_options(origin.HostDefinedOptions()),
cached_data(data) {}
-
ScriptCompiler::Source::Source(Local string,
CachedData* data)
: source_string(string), cached_data(data) {}
diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc
index c938db9b579429..bd4a0fde702a7b 100644
--- a/deps/v8/src/api.cc
+++ b/deps/v8/src/api.cc
@@ -278,6 +278,9 @@ static ScriptOrigin GetScriptOriginForScript(i::Isolate* isolate,
i::Handle script) {
i::Handle scriptName(script->GetNameOrSourceURL(), isolate);
i::Handle source_map_url(script->source_mapping_url(), isolate);
+ // Backed out for ABI compatibility with V8 6.2
+ // i::Handle host_defined_options(script->host_defined_options(),
+ // isolate);
v8::Isolate* v8_isolate =
reinterpret_cast(script->GetIsolate());
ScriptOriginOptions options(script->origin_options());
@@ -290,7 +293,9 @@ static ScriptOrigin GetScriptOriginForScript(i::Isolate* isolate,
Utils::ToLocal(source_map_url),
v8::Boolean::New(v8_isolate, options.IsOpaque()),
v8::Boolean::New(v8_isolate, script->type() == i::Script::TYPE_WASM),
- v8::Boolean::New(v8_isolate, options.IsModule()));
+ v8::Boolean::New(v8_isolate, options.IsModule()) /*,
+ // Backed out for ABI compatibility with V8 6.2
+ Utils::ToLocal(host_defined_options) */);
return origin;
}
@@ -2082,6 +2087,23 @@ Local Script::Run() {
RETURN_TO_LOCAL_UNCHECKED(Run(context), Value);
}
+Local ScriptOrModule::GetResourceName() {
+ i::Handle obj = Utils::OpenHandle(this);
+ i::Isolate* isolate = obj->GetIsolate();
+ ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
+ i::Handle val(obj->name(), isolate);
+ return ToApiHandle(val);
+}
+
+Local ScriptOrModule::GetHostDefinedOptions() {
+ i::Handle obj = Utils::OpenHandle(this);
+ i::Isolate* isolate = obj->GetIsolate();
+ ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
+ // Backed out for ABI compatibility with V8 6.2
+ // i::Handle val(obj->host_defined_options(), isolate);
+ // return ToApiHandle(val);
+ return Local();
+}
Local Script::GetUnboundScript() {
i::Handle obj = Utils::OpenHandle(this);
@@ -2089,6 +2111,46 @@ Local Script::GetUnboundScript() {
i::Handle(i::JSFunction::cast(*obj)->shared()));
}
+// static
+Local PrimitiveArray::New(Isolate* v8_isolate, int length) {
+ i::Isolate* isolate = reinterpret_cast(v8_isolate);
+ ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
+ Utils::ApiCheck(length >= 0, "v8::PrimitiveArray::New",
+ "length must be equal or greater than zero");
+ i::Handle array = isolate->factory()->NewFixedArray(length);
+ return ToApiHandle(array);
+}
+
+int PrimitiveArray::Length() const {
+ i::Handle array = Utils::OpenHandle(this);
+ i::Isolate* isolate = array->GetIsolate();
+ ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
+ return array->length();
+}
+
+void PrimitiveArray::Set(int index, Local item) {
+ i::Handle array = Utils::OpenHandle(this);
+ i::Isolate* isolate = array->GetIsolate();
+ ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
+ Utils::ApiCheck(index >= 0 && index < array->length(),
+ "v8::PrimitiveArray::Set",
+ "index must be greater than or equal to 0 and less than the "
+ "array length");
+ i::Handle i_item = Utils::OpenHandle(*item);
+ array->set(index, *i_item);
+}
+
+Local PrimitiveArray::Get(int index) {
+ i::Handle array = Utils::OpenHandle(this);
+ i::Isolate* isolate = array->GetIsolate();
+ ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
+ Utils::ApiCheck(index >= 0 && index < array->length(),
+ "v8::PrimitiveArray::Get",
+ "index must be greater than or equal to 0 and less than the "
+ "array length");
+ i::Handle i_item(array->get(index), isolate);
+ return ToApiHandle(i_item);
+}
Module::Status Module::GetStatus() const {
i::Handle self = Utils::OpenHandle(this);
@@ -2225,11 +2287,18 @@ MaybeLocal ScriptCompiler::CompileUnboundInternal(
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileScript");
i::Handle name_obj;
i::Handle source_map_url;
+ // Backed out for ABI compatibility with V8 6.2
+ // i::Handle host_defined_options =
+ // isolate->factory()->empty_fixed_array();
int line_offset = 0;
int column_offset = 0;
if (!source->resource_name.IsEmpty()) {
name_obj = Utils::OpenHandle(*(source->resource_name));
}
+ // Backed out for ABI compatibility with V8 6.2
+ // if (!source->host_defined_options.IsEmpty()) {
+ // host_defined_options = Utils::OpenHandle(*(source->host_defined_options));
+ // }
if (!source->resource_line_offset.IsEmpty()) {
line_offset = static_cast(source->resource_line_offset->Value());
}
@@ -2243,7 +2312,7 @@ MaybeLocal ScriptCompiler::CompileUnboundInternal(
result = i::Compiler::GetSharedFunctionInfoForScript(
str, name_obj, line_offset, column_offset, source->resource_options,
source_map_url, isolate->native_context(), NULL, &script_data, options,
- i::NOT_NATIVES_CODE);
+ i::NOT_NATIVES_CODE /*, host_defined_options */);
has_pending_exception = result.is_null();
if (has_pending_exception && script_data != NULL) {
// This case won't happen during normal operation; we have compiled
@@ -2508,6 +2577,10 @@ MaybeLocal |