diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index e14f5fc937d620..24b66f8b2f8b4d 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -13,7 +13,9 @@ Contributors guide: https://github.com/nodejs/node/blob/master/CONTRIBUTING.md - [ ] `make -j4 test` (UNIX), or `vcbuild test nosign` (Windows) passes - [ ] tests and/or benchmarks are included - [ ] documentation is changed or added -- [ ] commit message follows commit guidelines +- [ ] commit message follows [commit guidelines][] ##### Affected core subsystem(s) + +[commit guidelines]: https://github.com/nodejs/node/blob/master/CONTRIBUTING.md#commit-guidelines diff --git a/BUILDING.md b/BUILDING.md index 75ef93f8c73a13..2dd5c142779ead 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -13,7 +13,7 @@ file a new issue. Prerequisites: -* `gcc` and `g++` 4.8 or newer, or +* `gcc` and `g++` 4.8.5 or newer, or * `clang` and `clang++` 3.4 or newer * Python 2.6 or 2.7 * GNU Make 3.81 or newer diff --git a/CHANGELOG.md b/CHANGELOG.md index 818d612bc78a05..22116f1960d480 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,8 @@ release. - 7.7.3
+ 7.7.4
+ 7.7.3
7.7.2
7.7.1
7.7.0
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 290cad8faaeb7a..4daf126bd16053 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -95,6 +95,8 @@ $ git add my/changed/files $ git commit ``` +### Commit guidelines + Writing good commit logs is important. A commit log should describe what changed and why. Follow these guidelines when writing one: @@ -176,8 +178,7 @@ Running `make test`/`vcbuild test` will run the linter as well unless one or more tests fail. If you want to run the linter without running tests, use -`make lint`/`vcbuild jslint`. At this time, only JavaScript linting is -available on Windows. `make lint` on POSIX will run both JavaScript linting and +`make lint`/`vcbuild lint`. It will run both JavaScript linting and C++ linting. If you are updating tests and just want to run a single test to check it, you diff --git a/README.md b/README.md index 375119484b0770..5957e5e526c4cd 100644 --- a/README.md +++ b/README.md @@ -337,6 +337,8 @@ more information about the governance of the Node.js project, see **Mike Tunnicliffe** <m.j.tunnicliffe@gmail.com> * [vkurchatkin](https://github.com/vkurchatkin) - **Vladimir Kurchatkin** <vladimir.kurchatkin@gmail.com> +* [vsemozhetbyt](https://github.com/vsemozhetbyt) - +**Vse Mozhet Byt** <vsemozhetbyt@gmail.com> (he/him) * [watilde](https://github.com/watilde) - **Daijiro Wachi** <daijiro.wachi@gmail.com> (he/him) * [whitlockjc](https://github.com/whitlockjc) - diff --git a/benchmark/README.md b/benchmark/README.md index 6fd9a97bdfb3bb..17c733e6eb0b6c 100644 --- a/benchmark/README.md +++ b/benchmark/README.md @@ -235,12 +235,3 @@ it returns to accomplish what they need. This function reports timing data to the parent process (usually created by running `compare.js`, `run.js` or `scatter.js`). -### v8ForceOptimization(method[, ...args]) - -Force V8 to mark the `method` for optimization with the native function -`%OptimizeFunctionOnNextCall()` and return the optimization status -after that. - -It can be used to prevent the benchmark from getting disrupted by the optimizer -kicking in halfway through. However, this could result in a less effective -optimization. In general, only use it if you know what it actually does. diff --git a/benchmark/buffers/buffer-compare-instance-method.js b/benchmark/buffers/buffer-compare-instance-method.js index bb07326f3de218..ff3bc4c1abda98 100644 --- a/benchmark/buffers/buffer-compare-instance-method.js +++ b/benchmark/buffers/buffer-compare-instance-method.js @@ -1,6 +1,5 @@ 'use strict'; const common = require('../common.js'); -const v8 = require('v8'); const bench = common.createBenchmark(main, { size: [16, 512, 1024, 4096, 16386], @@ -20,7 +19,6 @@ function main(conf) { b1[size - 1] = 'b'.charCodeAt(0); - // Force optimization before starting the benchmark switch (args) { case 2: b0.compare(b1, 0); @@ -37,8 +35,6 @@ function main(conf) { default: b0.compare(b1); } - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(b0.compare)'); switch (args) { case 2: b0.compare(b1, 0); diff --git a/benchmark/buffers/buffer-compare-offset.js b/benchmark/buffers/buffer-compare-offset.js index 17b36f82883426..fd8c96dbce0158 100644 --- a/benchmark/buffers/buffer-compare-offset.js +++ b/benchmark/buffers/buffer-compare-offset.js @@ -1,6 +1,5 @@ 'use strict'; const common = require('../common.js'); -const v8 = require('v8'); const bench = common.createBenchmark(main, { method: ['offset', 'slice'], @@ -9,18 +8,6 @@ const bench = common.createBenchmark(main, { }); function compareUsingSlice(b0, b1, len, iter) { - - // Force optimization before starting the benchmark - Buffer.compare(b0.slice(1, len), b1.slice(1, len)); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(Buffer.compare)'); - eval('%OptimizeFunctionOnNextCall(b0.slice)'); - eval('%OptimizeFunctionOnNextCall(b1.slice)'); - Buffer.compare(b0.slice(1, len), b1.slice(1, len)); - doCompareUsingSlice(b0, b1, len, iter); -} - -function doCompareUsingSlice(b0, b1, len, iter) { var i; bench.start(); for (i = 0; i < iter; i++) @@ -29,16 +16,6 @@ function doCompareUsingSlice(b0, b1, len, iter) { } function compareUsingOffset(b0, b1, len, iter) { - len = len + 1; - // Force optimization before starting the benchmark - b0.compare(b1, 1, len, 1, len); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(b0.compare)'); - b0.compare(b1, 1, len, 1, len); - doCompareUsingOffset(b0, b1, len, iter); -} - -function doCompareUsingOffset(b0, b1, len, iter) { var i; bench.start(); for (i = 0; i < iter; i++) diff --git a/benchmark/buffers/buffer-swap.js b/benchmark/buffers/buffer-swap.js index c6d7db470bc69a..71e08890910843 100644 --- a/benchmark/buffers/buffer-swap.js +++ b/benchmark/buffers/buffer-swap.js @@ -1,7 +1,6 @@ 'use strict'; const common = require('../common.js'); -const v8 = require('v8'); const bench = common.createBenchmark(main, { aligned: ['true', 'false'], @@ -81,9 +80,7 @@ function main(conf) { const buf = createBuffer(len, aligned === 'true'); const bufferSwap = genMethod(method); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(bufferSwap)'); - + bufferSwap(n, buf); bench.start(); bufferSwap(n, buf); bench.end(n); diff --git a/benchmark/child_process/child-process-params.js b/benchmark/child_process/child-process-params.js new file mode 100644 index 00000000000000..644b2136a0f03f --- /dev/null +++ b/benchmark/child_process/child-process-params.js @@ -0,0 +1,146 @@ +'use strict'; + +const common = require('../common.js'); +const cp = require('child_process'); + +const command = 'echo'; +const args = ['hello']; +const options = {}; +const cb = () => {}; + +const configs = { + n: [1e3], + methodName: [ + 'exec', 'execSync', + 'execFile', 'execFileSync', + 'spawn', 'spawnSync', + ], + params: [1, 2, 3, 4], +}; + +const bench = common.createBenchmark(main, configs); + +function main(conf) { + const n = +conf.n; + const methodName = conf.methodName; + const params = +conf.params; + + const method = cp[methodName]; + + switch (methodName) { + case 'exec': + switch (params) { + case 1: + bench.start(); + for (let i = 0; i < n; i++) method(command).kill(); + bench.end(n); + break; + case 2: + bench.start(); + for (let i = 0; i < n; i++) method(command, options).kill(); + bench.end(n); + break; + case 3: + bench.start(); + for (let i = 0; i < n; i++) method(command, options, cb).kill(); + bench.end(n); + break; + } + break; + case 'execSync': + switch (params) { + case 1: + bench.start(); + for (let i = 0; i < n; i++) method(command); + bench.end(n); + break; + case 2: + bench.start(); + for (let i = 0; i < n; i++) method(command, options); + bench.end(n); + break; + } + break; + case 'execFile': + switch (params) { + case 1: + bench.start(); + for (let i = 0; i < n; i++) method(command).kill(); + bench.end(n); + break; + case 2: + bench.start(); + for (let i = 0; i < n; i++) method(command, args).kill(); + bench.end(n); + break; + case 3: + bench.start(); + for (let i = 0; i < n; i++) method(command, args, options).kill(); + bench.end(n); + break; + case 4: + bench.start(); + for (let i = 0; i < n; i++) method(command, args, options, cb).kill(); + bench.end(n); + break; + } + break; + case 'execFileSync': + switch (params) { + case 1: + bench.start(); + for (let i = 0; i < n; i++) method(command); + bench.end(n); + break; + case 2: + bench.start(); + for (let i = 0; i < n; i++) method(command, args); + bench.end(n); + break; + case 3: + bench.start(); + for (let i = 0; i < n; i++) method(command, args, options); + bench.end(n); + break; + } + break; + case 'spawn': + switch (params) { + case 1: + bench.start(); + for (let i = 0; i < n; i++) method(command).kill(); + bench.end(n); + break; + case 2: + bench.start(); + for (let i = 0; i < n; i++) method(command, args).kill(); + bench.end(n); + break; + case 3: + bench.start(); + for (let i = 0; i < n; i++) method(command, args, options).kill(); + bench.end(n); + break; + } + break; + case 'spawnSync': + switch (params) { + case 1: + bench.start(); + for (let i = 0; i < n; i++) method(command); + bench.end(n); + break; + case 2: + bench.start(); + for (let i = 0; i < n; i++) method(command, args); + bench.end(n); + break; + case 3: + bench.start(); + for (let i = 0; i < n; i++) method(command, args, options); + bench.end(n); + break; + } + break; + } +} diff --git a/benchmark/common.js b/benchmark/common.js index 6a9b2ba0f71681..7ce180fdb7ff0a 100644 --- a/benchmark/common.js +++ b/benchmark/common.js @@ -229,17 +229,3 @@ Benchmark.prototype.report = function(rate, elapsed) { type: 'report' }); }; - -exports.v8ForceOptimization = function(method) { - if (typeof method !== 'function') - return; - - const v8 = require('v8'); - v8.setFlagsFromString('--allow_natives_syntax'); - - const args = Array.prototype.slice.call(arguments, 1); - method.apply(null, args); - eval('%OptimizeFunctionOnNextCall(method)'); - method.apply(null, args); - return eval('%GetOptimizationStatus(method)'); -}; diff --git a/benchmark/crypto/get-ciphers.js b/benchmark/crypto/get-ciphers.js index 257c9af2fd531e..3f5ad17ad38716 100644 --- a/benchmark/crypto/get-ciphers.js +++ b/benchmark/crypto/get-ciphers.js @@ -12,9 +12,12 @@ function main(conf) { const v = conf.v; const method = require(v).getCiphers; var i = 0; - - common.v8ForceOptimization(method); + // first call to getChipers will dominate the results + if (n > 1) { + for (; i < n; i++) + method(); + } bench.start(); - for (; i < n; i++) method(); + for (i = 0; i < n; i++) method(); bench.end(n); } diff --git a/benchmark/es/defaultparams-bench.js b/benchmark/es/defaultparams-bench.js index 1b962cfb39333f..56d04cd95bb454 100644 --- a/benchmark/es/defaultparams-bench.js +++ b/benchmark/es/defaultparams-bench.js @@ -22,8 +22,6 @@ function defaultParams(x = 1, y = 2) { function runOldStyleDefaults(n) { - common.v8ForceOptimization(oldStyleDefaults); - var i = 0; bench.start(); for (; i < n; i++) @@ -33,8 +31,6 @@ function runOldStyleDefaults(n) { function runDefaultParams(n) { - common.v8ForceOptimization(defaultParams); - var i = 0; bench.start(); for (; i < n; i++) diff --git a/benchmark/es/foreach-bench.js b/benchmark/es/foreach-bench.js new file mode 100644 index 00000000000000..fea5318bc6669b --- /dev/null +++ b/benchmark/es/foreach-bench.js @@ -0,0 +1,82 @@ +'use strict'; + +const common = require('../common.js'); + +const bench = common.createBenchmark(main, { + method: ['for', 'for-of', 'for-in', 'forEach'], + count: [5, 10, 20, 100], + millions: [5] +}); + +function useFor(n, items, count) { + var i, j; + bench.start(); + for (i = 0; i < n; i++) { + for (j = 0; j < count; j++) { + /* eslint-disable no-unused-vars */ + var item = items[j]; + /* esline-enable no-unused-vars */ + } + } + bench.end(n / 1e6); +} + +function useForOf(n, items) { + var i, item; + bench.start(); + for (i = 0; i < n; i++) { + for (item of items) {} + } + bench.end(n / 1e6); +} + +function useForIn(n, items) { + var i, j, item; + bench.start(); + for (i = 0; i < n; i++) { + for (j in items) { + /* eslint-disable no-unused-vars */ + item = items[j]; + /* esline-enable no-unused-vars */ + } + } + bench.end(n / 1e6); +} + +function useForEach(n, items) { + var i; + bench.start(); + for (i = 0; i < n; i++) { + items.forEach((item) => {}); + } + bench.end(n / 1e6); +} + +function main(conf) { + const n = +conf.millions * 1e6; + const count = +conf.count; + + const items = new Array(count); + var i; + var fn; + for (i = 0; i < count; i++) + items[i] = i; + + switch (conf.method) { + case 'for': + fn = useFor; + break; + case 'for-of': + fn = useForOf; + break; + case 'for-in': + fn = useForIn; + break; + case 'forEach': + fn = useForEach; + break; + default: + throw new Error('Unexpected method'); + } + fn(n, items, count); +} diff --git a/benchmark/es/restparams-bench.js b/benchmark/es/restparams-bench.js index 0ff9c48dedc490..f5c49dd969b40a 100644 --- a/benchmark/es/restparams-bench.js +++ b/benchmark/es/restparams-bench.js @@ -35,8 +35,6 @@ function useArguments() { function runCopyArguments(n) { - common.v8ForceOptimization(copyArguments, 1, 2, 'a', 'b'); - var i = 0; bench.start(); for (; i < n; i++) @@ -46,8 +44,6 @@ function runCopyArguments(n) { function runRestArguments(n) { - common.v8ForceOptimization(restArguments, 1, 2, 'a', 'b'); - var i = 0; bench.start(); for (; i < n; i++) @@ -57,8 +53,6 @@ function runRestArguments(n) { function runUseArguments(n) { - common.v8ForceOptimization(useArguments, 1, 2, 'a', 'b'); - var i = 0; bench.start(); for (; i < n; i++) diff --git a/benchmark/misc/console.js b/benchmark/misc/console.js index 9a08a411c51f82..9c5aec0eeeb5fa 100644 --- a/benchmark/misc/console.js +++ b/benchmark/misc/console.js @@ -4,9 +4,6 @@ const common = require('../common.js'); const assert = require('assert'); const Writable = require('stream').Writable; const util = require('util'); -const v8 = require('v8'); - -v8.setFlagsFromString('--allow_natives_syntax'); const methods = [ 'restAndSpread', @@ -51,14 +48,7 @@ function usingArgumentsAndApplyC() { nullStream.write(util.format.apply(null, arguments) + '\n'); } -function optimize(method, ...args) { - method(...args); - eval(`%OptimizeFunctionOnNextCall(${method.name})`); - method(...args); -} - function runUsingRestAndConcat(n) { - optimize(usingRestAndConcat, 'a', 1); var i = 0; bench.start(); @@ -70,7 +60,6 @@ function runUsingRestAndConcat(n) { function runUsingRestAndSpread(n, concat) { const method = concat ? usingRestAndSpreadC : usingRestAndSpreadTS; - optimize(method, 'this is %s of %d', 'a', 1); var i = 0; bench.start(); @@ -82,7 +71,6 @@ function runUsingRestAndSpread(n, concat) { function runUsingRestAndApply(n, concat) { const method = concat ? usingRestAndApplyC : usingRestAndApplyTS; - optimize(method, 'this is %s of %d', 'a', 1); var i = 0; bench.start(); @@ -94,7 +82,6 @@ function runUsingRestAndApply(n, concat) { function runUsingArgumentsAndApply(n, concat) { const method = concat ? usingArgumentsAndApplyC : usingArgumentsAndApplyTS; - optimize(method, 'this is %s of %d', 'a', 1); var i = 0; bench.start(); diff --git a/benchmark/misc/punycode.js b/benchmark/misc/punycode.js index f4d22557ac5d65..74ddadbb9daa6c 100644 --- a/benchmark/misc/punycode.js +++ b/benchmark/misc/punycode.js @@ -42,16 +42,16 @@ function usingICU(val) { } function runPunycode(n, val) { - common.v8ForceOptimization(usingPunycode, val); var i = 0; - bench.start(); for (; i < n; i++) usingPunycode(val); + bench.start(); + for (i = 0; i < n; i++) + usingPunycode(val); bench.end(n); } function runICU(n, val) { - common.v8ForceOptimization(usingICU, val); var i = 0; bench.start(); for (; i < n; i++) diff --git a/benchmark/misc/util-extend-vs-object-assign.js b/benchmark/misc/util-extend-vs-object-assign.js index caea42ce914cf5..41c15d7d2caa0c 100644 --- a/benchmark/misc/util-extend-vs-object-assign.js +++ b/benchmark/misc/util-extend-vs-object-assign.js @@ -2,7 +2,6 @@ const common = require('../common.js'); const util = require('util'); -const v8 = require('v8'); const bench = common.createBenchmark(main, { type: ['extend', 'assign'], @@ -12,15 +11,11 @@ const bench = common.createBenchmark(main, { function main(conf) { let fn; const n = conf.n | 0; - let v8command; if (conf.type === 'extend') { fn = util._extend; - v8command = '%OptimizeFunctionOnNextCall(util._extend)'; } else if (conf.type === 'assign') { fn = Object.assign; - // Object.assign is built-in, cannot be optimized - v8command = ''; } // Force-optimize the method to test so that the benchmark doesn't @@ -28,9 +23,6 @@ function main(conf) { for (var i = 0; i < conf.type.length * 10; i += 1) fn({}, process.env); - v8.setFlagsFromString('--allow_natives_syntax'); - eval(v8command); - var obj = new Proxy({}, { set: function(a, b, c) { return true; } }); bench.start(); diff --git a/benchmark/path/basename-posix.js b/benchmark/path/basename-posix.js index 64da9017793440..fc983c8074c940 100644 --- a/benchmark/path/basename-posix.js +++ b/benchmark/path/basename-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { pathext: [ @@ -30,12 +29,6 @@ function main(conf) { input = input.slice(0, extIdx); } - // Force optimization before starting the benchmark - p.basename(input, ext); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.basename)'); - p.basename(input, ext); - bench.start(); for (var i = 0; i < n; i++) { p.basename(input, ext); diff --git a/benchmark/path/basename-win32.js b/benchmark/path/basename-win32.js index a6214598790033..b493beb87c9e94 100644 --- a/benchmark/path/basename-win32.js +++ b/benchmark/path/basename-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { pathext: [ @@ -30,12 +29,6 @@ function main(conf) { input = input.slice(0, extIdx); } - // Force optimization before starting the benchmark - p.basename(input, ext); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.basename)'); - p.basename(input, ext); - bench.start(); for (var i = 0; i < n; i++) { p.basename(input, ext); diff --git a/benchmark/path/dirname-posix.js b/benchmark/path/dirname-posix.js index e7ea80ffa313c8..af77be5ac06559 100644 --- a/benchmark/path/dirname-posix.js +++ b/benchmark/path/dirname-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -21,12 +20,6 @@ function main(conf) { var p = path.posix; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.dirname(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.dirname)'); - p.dirname(input); - bench.start(); for (var i = 0; i < n; i++) { p.dirname(input); diff --git a/benchmark/path/dirname-win32.js b/benchmark/path/dirname-win32.js index 5cb0829437c2ed..01d97d08e2ae05 100644 --- a/benchmark/path/dirname-win32.js +++ b/benchmark/path/dirname-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -21,12 +20,6 @@ function main(conf) { var p = path.win32; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.dirname(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.dirname)'); - p.dirname(input); - bench.start(); for (var i = 0; i < n; i++) { p.dirname(input); diff --git a/benchmark/path/extname-posix.js b/benchmark/path/extname-posix.js index 61a1073158f8d3..50c4e8f7927ba6 100644 --- a/benchmark/path/extname-posix.js +++ b/benchmark/path/extname-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -24,12 +23,6 @@ function main(conf) { var p = path.posix; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.extname(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.extname)'); - p.extname(input); - bench.start(); for (var i = 0; i < n; i++) { p.extname(input); diff --git a/benchmark/path/extname-win32.js b/benchmark/path/extname-win32.js index 67e53eab85817f..9c0df13ab46105 100644 --- a/benchmark/path/extname-win32.js +++ b/benchmark/path/extname-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -24,12 +23,6 @@ function main(conf) { var p = path.win32; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.extname(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.extname)'); - p.extname(input); - bench.start(); for (var i = 0; i < n; i++) { p.extname(input); diff --git a/benchmark/path/format-posix.js b/benchmark/path/format-posix.js index b30b58be4118f0..ee78a6d5f30980 100644 --- a/benchmark/path/format-posix.js +++ b/benchmark/path/format-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { props: [ @@ -22,12 +21,6 @@ function main(conf) { name: props[4] || '', }; - // Force optimization before starting the benchmark - p.format(obj); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.format)'); - p.format(obj); - bench.start(); for (var i = 0; i < n; i++) { p.format(obj); diff --git a/benchmark/path/format-win32.js b/benchmark/path/format-win32.js index 7404f2e93e6868..9ec981d6310ed6 100644 --- a/benchmark/path/format-win32.js +++ b/benchmark/path/format-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { props: [ @@ -22,12 +21,6 @@ function main(conf) { name: props[4] || '', }; - // Force optimization before starting the benchmark - p.format(obj); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.format)'); - p.format(obj); - bench.start(); for (var i = 0; i < n; i++) { p.format(obj); diff --git a/benchmark/path/isAbsolute-posix.js b/benchmark/path/isAbsolute-posix.js index fb8956c073b9db..22db751100ceee 100644 --- a/benchmark/path/isAbsolute-posix.js +++ b/benchmark/path/isAbsolute-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -19,12 +18,6 @@ function main(conf) { var p = path.posix; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.isAbsolute(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.isAbsolute)'); - p.isAbsolute(input); - bench.start(); for (var i = 0; i < n; i++) { p.isAbsolute(input); diff --git a/benchmark/path/isAbsolute-win32.js b/benchmark/path/isAbsolute-win32.js index 57fb8b8999e838..a565da8e566f8f 100644 --- a/benchmark/path/isAbsolute-win32.js +++ b/benchmark/path/isAbsolute-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -20,12 +19,6 @@ function main(conf) { var p = path.win32; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.isAbsolute(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.isAbsolute)'); - p.isAbsolute(input); - bench.start(); for (var i = 0; i < n; i++) { p.isAbsolute(input); diff --git a/benchmark/path/join-posix.js b/benchmark/path/join-posix.js index 1222f4050aa6ab..a7cf3772522daa 100644 --- a/benchmark/path/join-posix.js +++ b/benchmark/path/join-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { paths: [ @@ -15,12 +14,6 @@ function main(conf) { var p = path.posix; var args = ('' + conf.paths).split('|'); - // Force optimization before starting the benchmark - p.join.apply(null, args); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.join)'); - p.join.apply(null, args); - bench.start(); for (var i = 0; i < n; i++) { p.join.apply(null, args); diff --git a/benchmark/path/join-win32.js b/benchmark/path/join-win32.js index 86801859d56c3b..18c1e802a6bff1 100644 --- a/benchmark/path/join-win32.js +++ b/benchmark/path/join-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { paths: [ @@ -15,12 +14,6 @@ function main(conf) { var p = path.win32; var args = ('' + conf.paths).split('|'); - // Force optimization before starting the benchmark - p.join.apply(null, args); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.join)'); - p.join.apply(null, args); - bench.start(); for (var i = 0; i < n; i++) { p.join.apply(null, args); diff --git a/benchmark/path/makeLong-win32.js b/benchmark/path/makeLong-win32.js index d4b29d7e709b3e..fe5da425a5cd73 100644 --- a/benchmark/path/makeLong-win32.js +++ b/benchmark/path/makeLong-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -18,12 +17,6 @@ function main(conf) { var p = path.win32; var input = '' + conf.path; - // Force optimization before starting the benchmark - p._makeLong(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p._makeLong)'); - p._makeLong(input); - bench.start(); for (var i = 0; i < n; i++) { p._makeLong(input); diff --git a/benchmark/path/normalize-posix.js b/benchmark/path/normalize-posix.js index 19d6461ca51dcf..aec703cbe21242 100644 --- a/benchmark/path/normalize-posix.js +++ b/benchmark/path/normalize-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -20,12 +19,6 @@ function main(conf) { var p = path.posix; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.normalize(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.normalize)'); - p.normalize(input); - bench.start(); for (var i = 0; i < n; i++) { p.normalize(input); diff --git a/benchmark/path/normalize-win32.js b/benchmark/path/normalize-win32.js index 119f9797681113..356d399c3513ab 100644 --- a/benchmark/path/normalize-win32.js +++ b/benchmark/path/normalize-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -20,12 +19,6 @@ function main(conf) { var p = path.win32; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.normalize(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.normalize)'); - p.normalize(input); - bench.start(); for (var i = 0; i < n; i++) { p.normalize(input); diff --git a/benchmark/path/parse-posix.js b/benchmark/path/parse-posix.js index ee4306fcd27496..997eec0452b74a 100644 --- a/benchmark/path/parse-posix.js +++ b/benchmark/path/parse-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -21,15 +20,12 @@ function main(conf) { var p = path.posix; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.parse(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.parse)'); - p.parse(input); - - bench.start(); for (var i = 0; i < n; i++) { p.parse(input); } + bench.start(); + for (i = 0; i < n; i++) { + p.parse(input); + } bench.end(n); } diff --git a/benchmark/path/parse-win32.js b/benchmark/path/parse-win32.js index 5a7b80f0ddb3da..2a95f758665377 100644 --- a/benchmark/path/parse-win32.js +++ b/benchmark/path/parse-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -22,15 +21,12 @@ function main(conf) { var p = path.win32; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.parse(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.parse)'); - p.parse(input); - - bench.start(); for (var i = 0; i < n; i++) { p.parse(input); } + bench.start(); + for (i = 0; i < n; i++) { + p.parse(input); + } bench.end(n); } diff --git a/benchmark/path/relative-posix.js b/benchmark/path/relative-posix.js index 7544fb2dc67e7d..492b73c3e89f8a 100644 --- a/benchmark/path/relative-posix.js +++ b/benchmark/path/relative-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { paths: [ @@ -26,15 +25,12 @@ function main(conf) { to = from.slice(delimIdx + 1); from = from.slice(0, delimIdx); } - - // Force optimization before starting the benchmark - p.relative(from, to); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.relative)'); - p.relative(from, to); + for (var i = 0; i < n; i++) { + p.relative(from, to); + } bench.start(); - for (var i = 0; i < n; i++) { + for (i = 0; i < n; i++) { p.relative(from, to); } bench.end(n); diff --git a/benchmark/path/relative-win32.js b/benchmark/path/relative-win32.js index 92531959c1c3aa..7e7620299eb16c 100644 --- a/benchmark/path/relative-win32.js +++ b/benchmark/path/relative-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { paths: [ @@ -25,14 +24,13 @@ function main(conf) { from = from.slice(0, delimIdx); } - // Force optimization before starting the benchmark - p.relative(from, to); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.relative)'); - p.relative(from, to); + // Warmup + for (var i = 0; i < n; i++) { + p.relative(from, to); + } bench.start(); - for (var i = 0; i < n; i++) { + for (i = 0; i < n; i++) { p.relative(from, to); } bench.end(n); diff --git a/benchmark/path/resolve-posix.js b/benchmark/path/resolve-posix.js index 93e5b82191a23a..d1364a8ac256c9 100644 --- a/benchmark/path/resolve-posix.js +++ b/benchmark/path/resolve-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { paths: [ @@ -18,12 +17,6 @@ function main(conf) { var p = path.posix; var args = ('' + conf.paths).split('|'); - // Force optimization before starting the benchmark - p.resolve.apply(null, args); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.resolve)'); - p.resolve.apply(null, args); - bench.start(); for (var i = 0; i < n; i++) { p.resolve.apply(null, args); diff --git a/benchmark/path/resolve-win32.js b/benchmark/path/resolve-win32.js index dc0eb30e930049..6dfb38167c96bd 100644 --- a/benchmark/path/resolve-win32.js +++ b/benchmark/path/resolve-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { paths: [ @@ -18,12 +17,6 @@ function main(conf) { var p = path.win32; var args = ('' + conf.paths).split('|'); - // Force optimization before starting the benchmark - p.resolve.apply(null, args); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.resolve)'); - p.resolve.apply(null, args); - bench.start(); for (var i = 0; i < n; i++) { p.resolve.apply(null, args); diff --git a/benchmark/querystring/querystring-parse.js b/benchmark/querystring/querystring-parse.js index 2e2ec1417bcd35..888ce6320a30d9 100644 --- a/benchmark/querystring/querystring-parse.js +++ b/benchmark/querystring/querystring-parse.js @@ -1,8 +1,6 @@ 'use strict'; var common = require('../common.js'); var querystring = require('querystring'); -var v8 = require('v8'); - var inputs = require('../fixtures/url-inputs.js').searchParams; var bench = common.createBenchmark(main, { @@ -14,21 +12,18 @@ function main(conf) { var type = conf.type; var n = conf.n | 0; var input = inputs[type]; + var i; - // Force-optimize querystring.parse() so that the benchmark doesn't get + // Optimize querystring.parse() so that the benchmark doesn't get // disrupted by the optimizer kicking in halfway through. - v8.setFlagsFromString('--allow_natives_syntax'); if (type !== 'multicharsep') { - querystring.parse(input); - eval('%OptimizeFunctionOnNextCall(querystring.parse)'); - querystring.parse(input); + for (i = 0; i < n; i += 1) + querystring.parse(input); } else { - querystring.parse(input, '&&&&&&&&&&'); - eval('%OptimizeFunctionOnNextCall(querystring.parse)'); - querystring.parse(input, '&&&&&&&&&&'); + for (i = 0; i < n; i += 1) + querystring.parse(input, '&&&&&&&&&&'); } - var i; if (type !== 'multicharsep') { bench.start(); for (i = 0; i < n; i += 1) diff --git a/benchmark/querystring/querystring-stringify.js b/benchmark/querystring/querystring-stringify.js index 5870a690555a0a..7e31a49e99e54c 100644 --- a/benchmark/querystring/querystring-stringify.js +++ b/benchmark/querystring/querystring-stringify.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var querystring = require('querystring'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { type: ['noencode', 'encodemany', 'encodelast'], @@ -36,10 +35,6 @@ function main(conf) { for (var name in inputs) querystring.stringify(inputs[name]); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(querystring.stringify)'); - querystring.stringify(input); - bench.start(); for (var i = 0; i < n; i += 1) querystring.stringify(input); diff --git a/benchmark/streams/readable-bigread.js b/benchmark/streams/readable-bigread.js index 50f10c44119141..34d478fb478478 100644 --- a/benchmark/streams/readable-bigread.js +++ b/benchmark/streams/readable-bigread.js @@ -1,7 +1,6 @@ 'use strict'; const common = require('../common'); -const v8 = require('v8'); const Readable = require('stream').Readable; const bench = common.createBenchmark(main, { @@ -15,13 +14,6 @@ function main(conf) { function noop() {} s._read = noop; - // Force optimization before starting the benchmark - s.push(b); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(s.read)'); - s.push(b); - while (s.read(128)); - bench.start(); for (var k = 0; k < n; ++k) { for (var i = 0; i < 1e4; ++i) diff --git a/benchmark/streams/readable-bigunevenread.js b/benchmark/streams/readable-bigunevenread.js index ce6e41c5d30eac..d176166ae4f432 100644 --- a/benchmark/streams/readable-bigunevenread.js +++ b/benchmark/streams/readable-bigunevenread.js @@ -1,7 +1,6 @@ 'use strict'; const common = require('../common'); -const v8 = require('v8'); const Readable = require('stream').Readable; const bench = common.createBenchmark(main, { @@ -15,13 +14,6 @@ function main(conf) { function noop() {} s._read = noop; - // Force optimization before starting the benchmark - s.push(b); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(s.read)'); - s.push(b); - while (s.read(106)); - bench.start(); for (var k = 0; k < n; ++k) { for (var i = 0; i < 1e4; ++i) diff --git a/benchmark/streams/readable-boundaryread.js b/benchmark/streams/readable-boundaryread.js index 93a6616361ba18..1a0b7eb7ac9ddc 100644 --- a/benchmark/streams/readable-boundaryread.js +++ b/benchmark/streams/readable-boundaryread.js @@ -1,7 +1,6 @@ 'use strict'; const common = require('../common'); -const v8 = require('v8'); const Readable = require('stream').Readable; const bench = common.createBenchmark(main, { @@ -15,14 +14,6 @@ function main(conf) { function noop() {} s._read = noop; - // Force optimization before starting the benchmark - s.push(b); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(s.push)'); - eval('%OptimizeFunctionOnNextCall(s.read)'); - s.push(b); - while (s.read(32)); - bench.start(); for (var k = 0; k < n; ++k) { for (var i = 0; i < 1e4; ++i) diff --git a/benchmark/streams/readable-readall.js b/benchmark/streams/readable-readall.js index 07626fd7978b9a..be34afbeabc090 100644 --- a/benchmark/streams/readable-readall.js +++ b/benchmark/streams/readable-readall.js @@ -1,7 +1,6 @@ 'use strict'; const common = require('../common'); -const v8 = require('v8'); const Readable = require('stream').Readable; const bench = common.createBenchmark(main, { @@ -15,13 +14,6 @@ function main(conf) { function noop() {} s._read = noop; - // Force optimization before starting the benchmark - s.push(b); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(s.read)'); - s.push(b); - while (s.read()); - bench.start(); for (var k = 0; k < n; ++k) { for (var i = 0; i < 1e4; ++i) diff --git a/benchmark/streams/readable-unevenread.js b/benchmark/streams/readable-unevenread.js index 4a69bd97a94bcf..ebbc727ad23ec3 100644 --- a/benchmark/streams/readable-unevenread.js +++ b/benchmark/streams/readable-unevenread.js @@ -1,7 +1,6 @@ 'use strict'; const common = require('../common'); -const v8 = require('v8'); const Readable = require('stream').Readable; const bench = common.createBenchmark(main, { @@ -15,13 +14,6 @@ function main(conf) { function noop() {} s._read = noop; - // Force optimization before starting the benchmark - s.push(b); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(s.read)'); - s.push(b); - while (s.read(12)); - bench.start(); for (var k = 0; k < n; ++k) { for (var i = 0; i < 1e4; ++i) diff --git a/benchmark/tls/convertprotocols.js b/benchmark/tls/convertprotocols.js index 32da0fe6fde271..5d561455051a0c 100644 --- a/benchmark/tls/convertprotocols.js +++ b/benchmark/tls/convertprotocols.js @@ -12,8 +12,11 @@ function main(conf) { var i = 0; var m = {}; - common.v8ForceOptimization( - tls.convertNPNProtocols, ['ABC', 'XYZ123', 'FOO'], m); + // First call dominates results + if (n > 1) { + tls.convertNPNProtocols(['ABC', 'XYZ123', 'FOO'], m); + m = {}; + } bench.start(); for (; i < n; i++) tls.convertNPNProtocols(['ABC', 'XYZ123', 'FOO'], m); bench.end(n); diff --git a/benchmark/url/url-format.js b/benchmark/url/url-format.js index 886958406b91c5..771786d3350513 100644 --- a/benchmark/url/url-format.js +++ b/benchmark/url/url-format.js @@ -1,7 +1,6 @@ 'use strict'; const common = require('../common.js'); const url = require('url'); -const v8 = require('v8'); const inputs = { slashes: {slashes: true, host: 'localhost'}, @@ -24,9 +23,6 @@ function main(conf) { for (const name in inputs) url.format(inputs[name]); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(url.format)'); - bench.start(); for (var i = 0; i < n; i += 1) url.format(input); diff --git a/benchmark/url/url-resolve.js b/benchmark/url/url-resolve.js index 4335511ca6d2df..421a70ef6d59f1 100644 --- a/benchmark/url/url-resolve.js +++ b/benchmark/url/url-resolve.js @@ -1,7 +1,6 @@ 'use strict'; const common = require('../common.js'); const url = require('url'); -const v8 = require('v8'); const hrefs = require('../fixtures/url-inputs.js').urls; hrefs.noscheme = 'some.ran/dom/url.thing?oh=yes#whoo'; @@ -24,12 +23,6 @@ function main(conf) { const href = hrefs[conf.href]; const path = paths[conf.path]; - // Force-optimize url.resolve() so that the benchmark doesn't get - // disrupted by the optimizer kicking in halfway through. - url.resolve(href, path); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(url.resolve)'); - bench.start(); for (var i = 0; i < n; i += 1) url.resolve(href, path); diff --git a/benchmark/util/format.js b/benchmark/util/format.js index 8040554ba0861a..82e25b4c4c8127 100644 --- a/benchmark/util/format.js +++ b/benchmark/util/format.js @@ -2,7 +2,6 @@ const util = require('util'); const common = require('../common'); -const v8 = require('v8'); const types = [ 'string', 'number', @@ -29,12 +28,6 @@ function main(conf) { const input = inputs[type]; - v8.setFlagsFromString('--allow_natives_syntax'); - - util.format(input[0], input[1]); - eval('%OptimizeFunctionOnNextCall(util.format)'); - util.format(input[0], input[1]); - bench.start(); for (var i = 0; i < n; i++) { util.format(input[0], input[1]); diff --git a/common.gypi b/common.gypi index 3aad8e7722d57b..147cc70fa5d5df 100644 --- a/common.gypi +++ b/common.gypi @@ -43,7 +43,7 @@ 'v8_postmortem_support%': 'true', }], ['OS== "mac"', { - 'OBJ_DIR': '<(PRODUCT_DIR)/obj', + 'OBJ_DIR': '<(PRODUCT_DIR)/obj.target', 'V8_BASE': '<(PRODUCT_DIR)/libv8_base.a', }, { 'conditions': [ diff --git a/deps/node-inspect/CHANGELOG.md b/deps/node-inspect/CHANGELOG.md index 0a7ba1be94fb50..dc217a5ba2d564 100644 --- a/deps/node-inspect/CHANGELOG.md +++ b/deps/node-inspect/CHANGELOG.md @@ -1,3 +1,30 @@ +### 1.10.6 + +* chore: Fix usage text for embedded mode - **[@addaleax](https://github.com/addaleax)** [#20](https://github.com/nodejs/node-inspect/pull/20) + - [`b0779f5`](https://github.com/nodejs/node-inspect/commit/b0779f597104e9ada5681f64d7e714525b753511) **chore:** Fix usage text for embedded mode +* print 'ok' after connection - **[@ofrobots](https://github.com/ofrobots)** [#25](https://github.com/nodejs/node-inspect/pull/25) + - [`2a47125`](https://github.com/nodejs/node-inspect/commit/2a4712577f6996fbb078dcfcd7320c397685d76a) **fix:** print 'ok' after connection +* Make autocompletion in REPL work - **[@aqrln](https://github.com/aqrln)** [#28](https://github.com/nodejs/node-inspect/pull/28) + - [`ccab737`](https://github.com/nodejs/node-inspect/commit/ccab737399249a8c2230ed6adfec579c7d724364) **fix:** Make autocompletion in REPL work +* Remove console.error() statement - **[@aqrln](https://github.com/aqrln)** [#30](https://github.com/nodejs/node-inspect/pull/30) + - [`032b045`](https://github.com/nodejs/node-inspect/commit/032b045d4d73622c77b7ebcc26781c6ad98200b3) **style:** Remove console.error() statement +* Take --debug-port into account - **[@jkrems](https://github.com/jkrems)** [#26](https://github.com/nodejs/node-inspect/pull/26) + - [`054d4b1`](https://github.com/nodejs/node-inspect/commit/054d4b10e65f12a3a4b10b4c0ab2a4768cc5e893) **fix:** Take --debug-port into account +* Delay run until breakpoints are restored - **[@jkrems](https://github.com/jkrems)** [#34](https://github.com/nodejs/node-inspect/pull/34) + - [`802b88c`](https://github.com/nodejs/node-inspect/commit/802b88c8ad0a57608cb9e0cb4bf46ed683bb6344) **fix:** Delay run until breakpoints are restored + - [`2b93173`](https://github.com/nodejs/node-inspect/commit/2b93173d95e7f8b30d85603613cb2ae3b3ec18db) **fix:** Use single string for paused notice + - [`b4d5ee2`](https://github.com/nodejs/node-inspect/commit/b4d5ee2a3d25613b35a2e8e10a0eb75582cc5654) **fix:** Work around inconsistent handling of strict directive + - [`f6ccfc7`](https://github.com/nodejs/node-inspect/commit/f6ccfc7f4d00ad4fdf3b581b677f8d7f1699c44c) **fix:** Only restart after port is free + - [`8b101bf`](https://github.com/nodejs/node-inspect/commit/8b101bf669ca102df4980bfad3e0436ef1c2f1a4) **test:** Skip exact match on AIX +* [`a4e4b6f`](https://github.com/nodejs/node-inspect/commit/a4e4b6feeba4dedfd2c89ef32f39e813314d3bbd) **chore:** Fix repo info in package.json + + +### 1.10.5 + +* docs: minor edits to governance docs - **[@joshgav](https://github.com/joshgav)** [#17](https://github.com/buggerjs/node-inspect/pull/17) + - [`a70fe04`](https://github.com/buggerjs/node-inspect/commit/a70fe04bdde9b7c74588685066291f9b11183328) **docs:** minor edits to governance docs + + ### 1.10.4 * [`1c31bf7`](https://github.com/buggerjs/node-inspect/commit/1c31bf7d1b3ea1b424ae0662526596670cb506c9) **chore:** Support embedded mode diff --git a/deps/node-inspect/CONTRIBUTING.md b/deps/node-inspect/CONTRIBUTING.md index 08d333cce8321f..012d29471462de 100644 --- a/deps/node-inspect/CONTRIBUTING.md +++ b/deps/node-inspect/CONTRIBUTING.md @@ -4,8 +4,7 @@ This document outlines some of the practices we care about. If you have any questions or suggestions about the process, -feel free to [open an issue](#reporting-issues) -. +feel free to [open an issue](#reporting-issues). ## Code of Conduct @@ -13,11 +12,10 @@ The [Node.js Code of Conduct][] applies to this repo. [Node.js Code of Conduct]: https://github.com/nodejs/node/blob/master/CODE_OF_CONDUCT.md -## Code Contributions +## Governance -The nodereport project falls under the governance of the diagnostics -working group which is documented in: -https://github.com/nodejs/diagnostics/blob/master/GOVERNANCE.md. +This project falls under the governance of the Node.js Diagnostics WG as +described at . ## Developer's Certificate of Origin 1.1 @@ -51,7 +49,7 @@ By making a contribution to this project, I certify that: If you find any mistakes in the docs or a bug in the code, please [open an issue in Github](https://github.com/nodejs/node-inspect/issues/new) so we can look into it. -You can also [create a PR](#contributing-code) fixing it yourself, or course. +You can also [create a PR](#contributing-code) fixing it yourself of course. If you report a bug, please follow these guidelines: @@ -67,7 +65,7 @@ If you report a bug, please follow these guidelines: For small documentation changes, you can use [Github's editing feature](https://help.github.com/articles/editing-files-in-another-user-s-repository/). The only thing to keep in mind is to prefix the commit message with "docs: ". -The detault commit message generated by Github will lead to a failing CI build. +The default commit message generated by Github will lead to a failing CI build. For larger updates to the documentation it might be better to follow the [instructions for contributing code below](#contributing-code). diff --git a/deps/node-inspect/GOVERNANCE.md b/deps/node-inspect/GOVERNANCE.md index 238c1b825837ac..20e333a247cbfd 100644 --- a/deps/node-inspect/GOVERNANCE.md +++ b/deps/node-inspect/GOVERNANCE.md @@ -1,5 +1,4 @@ # node-inspect Project Governance -The node-inspect project falls under the governance of the diagnostics -working group which is documented in: -https://github.com/nodejs/diagnostics/blob/master/GOVERNANCE.md. +The node-inspect project is governed by the Node.js Diagnostics WG as described +at . diff --git a/deps/node-inspect/examples/alive.js b/deps/node-inspect/examples/alive.js index 3cf557b053981e..c8ad157b452d11 100644 --- a/deps/node-inspect/examples/alive.js +++ b/deps/node-inspect/examples/alive.js @@ -1,4 +1,3 @@ -'use strict'; let x = 0; function heartbeat() { ++x; diff --git a/deps/node-inspect/examples/backtrace.js b/deps/node-inspect/examples/backtrace.js index f5d71a14f96f86..f18b33ea5584b2 100644 --- a/deps/node-inspect/examples/backtrace.js +++ b/deps/node-inspect/examples/backtrace.js @@ -1,4 +1,3 @@ -'use strict'; const { exports: moduleScoped } = module; function topFn(a, b = false) { diff --git a/deps/node-inspect/examples/cjs/index.js b/deps/node-inspect/examples/cjs/index.js index d5815e865999f7..0ace6d9b78591c 100644 --- a/deps/node-inspect/examples/cjs/index.js +++ b/deps/node-inspect/examples/cjs/index.js @@ -1,5 +1,5 @@ -'use strict'; +const fourty = 40; const { add } = require('./other'); -const sum = add(40, 2); +const sum = add(fourty, 2); module.exports = sum; diff --git a/deps/node-inspect/examples/cjs/other.js b/deps/node-inspect/examples/cjs/other.js index efadaa18d26e6d..44a9a439bab987 100644 --- a/deps/node-inspect/examples/cjs/other.js +++ b/deps/node-inspect/examples/cjs/other.js @@ -1,4 +1,3 @@ -'use strict'; exports.add = function add(a, b) { return a + b; }; diff --git a/deps/node-inspect/examples/exceptions.js b/deps/node-inspect/examples/exceptions.js index 00c48ed31b5113..f57d48a48dffc8 100644 --- a/deps/node-inspect/examples/exceptions.js +++ b/deps/node-inspect/examples/exceptions.js @@ -1,4 +1,3 @@ -'use strict'; let error = null; try { throw new Error('Caught'); diff --git a/deps/node-inspect/examples/three-lines.js b/deps/node-inspect/examples/three-lines.js index 4e1cb95d1130b8..c17c7c1ddcfe58 100644 --- a/deps/node-inspect/examples/three-lines.js +++ b/deps/node-inspect/examples/three-lines.js @@ -1,4 +1,3 @@ -'use strict'; let x = 1; x = x + 1; module.exports = x; diff --git a/deps/node-inspect/examples/use-strict.js b/deps/node-inspect/examples/use-strict.js new file mode 100644 index 00000000000000..9fe4b8f3b42f57 --- /dev/null +++ b/deps/node-inspect/examples/use-strict.js @@ -0,0 +1,2 @@ +'use strict'; +console.log('first real line'); diff --git a/deps/node-inspect/lib/_inspect.js b/deps/node-inspect/lib/_inspect.js index 5cd1cc2d685a90..ac32e0a6a432fa 100644 --- a/deps/node-inspect/lib/_inspect.js +++ b/deps/node-inspect/lib/_inspect.js @@ -22,10 +22,13 @@ 'use strict'; const { spawn } = require('child_process'); const { EventEmitter } = require('events'); +const net = require('net'); const util = require('util'); +const runAsStandalone = typeof __dirname !== 'undefined'; + const [ InspectClient, createRepl ] = - (typeof __dirname !== 'undefined') ? + runAsStandalone ? // This copy of node-inspect is on-disk, relative paths make sense. [ require('./internal/inspect_client'), @@ -39,7 +42,16 @@ const [ InspectClient, createRepl ] = const debuglog = util.debuglog('inspect'); -exports.port = 9229; +const DEBUG_PORT_PATTERN = /^--(?:debug|inspect)-port=(\d+)$/; +function getDefaultPort() { + for (const arg of process.execArgv) { + const match = arg.match(DEBUG_PORT_PATTERN); + if (match) { + return +match[1]; + } + } + return 9229; +} function runScript(script, scriptArgs, inspectPort, childPrint) { return new Promise((resolve) => { @@ -88,6 +100,45 @@ function createAgentProxy(domain, client) { }); } +function portIsFree(host, port, timeout = 2000) { + const retryDelay = 150; + let didTimeOut = false; + + return new Promise((resolve, reject) => { + setTimeout(() => { + didTimeOut = true; + reject(new Error( + `Timeout (${timeout}) waiting for ${host}:${port} to be free`)); + }, timeout); + + function pingPort() { + if (didTimeOut) return; + + const socket = net.connect(port, host); + let didRetry = false; + function retry() { + if (!didRetry && !didTimeOut) { + didRetry = true; + setTimeout(pingPort, retryDelay); + } + } + + socket.on('error', (error) => { + if (error.code === 'ECONNREFUSED') { + resolve(); + } else { + retry(); + } + }); + socket.on('connect', () => { + socket.destroy(); + retry(); + }); + } + pingPort(); + }); +} + class NodeInspector { constructor(options, stdin, stdout) { this.options = options; @@ -128,8 +179,9 @@ class NodeInspector { process.once('SIGHUP', process.exit.bind(process, 0)); this.run() - .then(() => { - this.repl = startRepl(); + .then(() => startRepl()) + .then((repl) => { + this.repl = repl; this.repl.on('exit', () => { process.exit(0); }); @@ -139,15 +191,19 @@ class NodeInspector { } suspendReplWhile(fn) { - this.repl.rli.pause(); + if (this.repl) { + this.repl.rli.pause(); + } this.stdin.pause(); this.paused = true; return new Promise((resolve) => { resolve(fn()); }).then(() => { this.paused = false; - this.repl.rli.resume(); - this.repl.displayPrompt(); + if (this.repl) { + this.repl.rli.resume(); + this.repl.displayPrompt(); + } this.stdin.resume(); }).then(null, (error) => process.nextTick(() => { throw error; })); } @@ -162,7 +218,14 @@ class NodeInspector { run() { this.killChild(); - return this._runScript().then((child) => { + const { host, port } = this.options; + + const runOncePortIsFree = () => { + return portIsFree(host, port) + .then(() => this._runScript()); + }; + + return runOncePortIsFree().then((child) => { this.child = child; let connectionAttempts = 0; @@ -173,6 +236,7 @@ class NodeInspector { return this.client.connect() .then(() => { debuglog('connection established'); + this.stdout.write(' ok'); }, (error) => { debuglog('connect failed', error); // If it's failed to connect 10 times then print failed message @@ -186,7 +250,6 @@ class NodeInspector { }); }; - const { host, port } = this.options; this.print(`connecting to ${host}:${port} ..`, true); return attemptConnect(); }); @@ -225,7 +288,7 @@ class NodeInspector { function parseArgv([target, ...args]) { let host = '127.0.0.1'; - let port = exports.port; + let port = getDefaultPort(); let isRemote = false; let script = target; let scriptArgs = args; @@ -258,8 +321,12 @@ function startInspect(argv = process.argv.slice(2), stdout = process.stdout) { /* eslint-disable no-console */ if (argv.length < 1) { - console.error('Usage: node-inspect script.js'); - console.error(' node-inspect :'); + const invokedAs = runAsStandalone ? + 'node-inspect' : + `${process.argv0} ${process.argv[1]}`; + + console.error(`Usage: ${invokedAs} script.js`); + console.error(` ${invokedAs} :`); process.exit(1); } diff --git a/deps/node-inspect/lib/internal/inspect_client.js b/deps/node-inspect/lib/internal/inspect_client.js index d5ce46db05c37d..c247e2add87706 100644 --- a/deps/node-inspect/lib/internal/inspect_client.js +++ b/deps/node-inspect/lib/internal/inspect_client.js @@ -334,20 +334,7 @@ class Client extends EventEmitter { this.emit('close'); }); - Promise.all([ - this.callMethod('Runtime.enable'), - this.callMethod('Debugger.enable'), - this.callMethod('Debugger.setPauseOnExceptions', { state: 'none' }), - this.callMethod('Debugger.setAsyncCallStackDepth', { maxDepth: 0 }), - this.callMethod('Profiler.enable'), - this.callMethod('Profiler.setSamplingInterval', { interval: 100 }), - this.callMethod('Debugger.setBlackboxPatterns', { patterns: [] }), - this.callMethod('Runtime.runIfWaitingForDebugger'), - ]).then(() => { - this.emit('ready'); - }, (error) => { - this.emit('error', error); - }); + this.emit('ready'); }; return new Promise((resolve, reject) => { diff --git a/deps/node-inspect/lib/internal/inspect_repl.js b/deps/node-inspect/lib/internal/inspect_repl.js index c61bbc9fb8e05a..2de86b247bb4b1 100644 --- a/deps/node-inspect/lib/internal/inspect_repl.js +++ b/deps/node-inspect/lib/internal/inspect_repl.js @@ -234,10 +234,10 @@ class ScopeSnapshot { constructor(scope, properties) { Object.assign(this, scope); this.properties = new Map(properties.map((prop) => { - // console.error(prop); const value = new RemoteObject(prop.value); return [prop.name, value]; })); + this.completionGroup = properties.map((prop) => prop.name); } [util.inspect.custom](depth, opts) { @@ -480,7 +480,9 @@ function createRepl(inspector) { if (!selectedFrame) { return Promise.reject(new Error('Requires execution to be paused')); } - return selectedFrame.loadScopes(); + return selectedFrame.loadScopes().then((scopes) => { + return scopes.map((scope) => scope.completionGroup); + }); } if (selectedFrame) { @@ -746,8 +748,8 @@ function createRepl(inspector) { .filter(({ location }) => !!location.scriptUrl) .map(({ location }) => setBreakpoint(location.scriptUrl, location.lineNumber + 1)); - if (!newBreakpoints.length) return; - Promise.all(newBreakpoints).then((results) => { + if (!newBreakpoints.length) return Promise.resolve(); + return Promise.all(newBreakpoints).then((results) => { print(`${results.length} breakpoints restored.`); }); } @@ -768,7 +770,8 @@ function createRepl(inspector) { const breakType = reason === 'other' ? 'break' : reason; const script = knownScripts[scriptId]; const scriptUrl = script ? getRelativePath(script.url) : '[unknown]'; - print(`${breakType} in ${scriptUrl}:${lineNumber + 1}`); + + const header = `${breakType} in ${scriptUrl}:${lineNumber + 1}`; inspector.suspendReplWhile(() => Promise.all([formatWatchers(true), selectedFrame.list(2)]) @@ -776,8 +779,10 @@ function createRepl(inspector) { if (watcherList) { return `${watcherList}\n${inspect(context)}`; } - return context; - }).then(print)); + return inspect(context); + }).then((breakContext) => { + print(`${header}\n${breakContext}`); + })); }); function handleResumed() { @@ -1024,7 +1029,30 @@ function createRepl(inspector) { aliasProperties(context, SHORTCUTS); } + function initAfterStart() { + const setupTasks = [ + Runtime.enable(), + Profiler.enable(), + Profiler.setSamplingInterval({ interval: 100 }), + Debugger.enable(), + Debugger.setPauseOnExceptions({ state: 'none' }), + Debugger.setAsyncCallStackDepth({ maxDepth: 0 }), + Debugger.setBlackboxPatterns({ patterns: [] }), + Debugger.setPauseOnExceptions({ state: pauseOnExceptionState }), + restoreBreakpoints(), + Runtime.runIfWaitingForDebugger(), + ]; + return Promise.all(setupTasks); + } + return function startRepl() { + inspector.client.on('close', () => { + resetOnStart(); + }); + inspector.client.on('ready', () => { + initAfterStart(); + }); + const replOptions = { prompt: 'debug> ', input: inspector.stdin, @@ -1033,6 +1061,7 @@ function createRepl(inspector) { useGlobal: false, ignoreUndefined: true, }; + repl = Repl.start(replOptions); // eslint-disable-line prefer-const initializeContext(repl.context); repl.on('reset', initializeContext); @@ -1042,14 +1071,8 @@ function createRepl(inspector) { repl.rli.emit('SIGINT'); }); - inspector.client.on('close', () => { - resetOnStart(); - }); - - inspector.client.on('ready', () => { - restoreBreakpoints(); - Debugger.setPauseOnExceptions({ state: pauseOnExceptionState }); - }); + // Init once for the initial connection + initAfterStart(); return repl; }; diff --git a/deps/node-inspect/package.json b/deps/node-inspect/package.json index f4b3aec6d94d5d..536a525e5c9bf5 100644 --- a/deps/node-inspect/package.json +++ b/deps/node-inspect/package.json @@ -1,17 +1,17 @@ { "name": "node-inspect", - "version": "1.10.4", + "version": "1.10.6", "description": "Node Inspect", "license": "MIT", "main": "lib/_inspect.js", "bin": "cli.js", - "homepage": "https://github.com/buggerjs/node-inspect", + "homepage": "https://github.com/nodejs/node-inspect", "repository": { "type": "git", - "url": "git+ssh://git@github.com/buggerjs/node-inspect" + "url": "git+ssh://git@github.com/nodejs/node-inspect" }, "bugs": { - "url": "https://github.com/buggerjs/node-inspect/issues" + "url": "https://github.com/nodejs/node-inspect/issues" }, "scripts": { "pretest": "eslint --rulesdir=tools/eslint-rules lib test", diff --git a/deps/node-inspect/test/cli/backtrace.test.js b/deps/node-inspect/test/cli/backtrace.test.js index 2e2ba4a3423360..9cd8a82a33f043 100644 --- a/deps/node-inspect/test/cli/backtrace.test.js +++ b/deps/node-inspect/test/cli/backtrace.test.js @@ -19,11 +19,11 @@ test('display and navigate backtrace', (t) => { .then(() => cli.stepCommand('c')) .then(() => cli.command('bt')) .then(() => { - t.match(cli.output, `#0 topFn ${script}:8:2`); + t.match(cli.output, `#0 topFn ${script}:7:2`); }) .then(() => cli.command('backtrace')) .then(() => { - t.match(cli.output, `#0 topFn ${script}:8:2`); + t.match(cli.output, `#0 topFn ${script}:7:2`); }) .then(() => cli.quit()) .then(null, onFatal); diff --git a/deps/node-inspect/test/cli/exceptions.test.js b/deps/node-inspect/test/cli/exceptions.test.js index 6d3ff68f057068..b66c09fc504424 100644 --- a/deps/node-inspect/test/cli/exceptions.test.js +++ b/deps/node-inspect/test/cli/exceptions.test.js @@ -31,11 +31,11 @@ test('break on (uncaught) exceptions', (t) => { .then(() => cli.command('breakOnException')) .then(() => cli.stepCommand('c')) .then(() => { - t.match(cli.output, `exception in ${script}:4`); + t.match(cli.output, `exception in ${script}:3`); }) .then(() => cli.stepCommand('c')) .then(() => { - t.match(cli.output, `exception in ${script}:10`); + t.match(cli.output, `exception in ${script}:9`); }) // Next run: With `breakOnUncaught` it only pauses on the 2nd exception @@ -46,7 +46,7 @@ test('break on (uncaught) exceptions', (t) => { }) .then(() => cli.stepCommand('c')) .then(() => { - t.match(cli.output, `exception in ${script}:10`); + t.match(cli.output, `exception in ${script}:9`); }) // Next run: Back to the initial state! It should die again. diff --git a/deps/node-inspect/test/cli/launch.test.js b/deps/node-inspect/test/cli/launch.test.js index 962197e84f2295..99c6ce0aa2efa1 100644 --- a/deps/node-inspect/test/cli/launch.test.js +++ b/deps/node-inspect/test/cli/launch.test.js @@ -8,7 +8,9 @@ const startCLI = require('./start-cli'); test('examples/empty.js', (t) => { const script = Path.join('examples', 'empty.js'); const cli = startCLI([script]); - return cli.waitForPrompt() + + return cli.waitFor(/break/) + .then(() => cli.waitForPrompt()) .then(() => { t.match(cli.output, 'debug>', 'prints a prompt'); t.match( diff --git a/deps/node-inspect/test/cli/preserve-breaks.test.js b/deps/node-inspect/test/cli/preserve-breaks.test.js index a248b3aa25605b..8de8227343626a 100644 --- a/deps/node-inspect/test/cli/preserve-breaks.test.js +++ b/deps/node-inspect/test/cli/preserve-breaks.test.js @@ -48,8 +48,17 @@ test('run after quit / restart', (t) => { }) .then(() => cli.command('breakpoints')) .then(() => { - t.match(cli.output, `#0 ${script}:2`); - t.match(cli.output, `#1 ${script}:3`); + if (process.platform === 'aix') { + // TODO: There is a known issue on AIX where the breakpoints aren't + // properly resolved yet when we reach this point. + // Eventually that should be figured out but for now we don't want + // to fail builds because of it. + t.match(cli.output, /#0 [^\n]+three-lines\.js\$?:2/); + t.match(cli.output, /#1 [^\n]+three-lines\.js\$?:3/); + } else { + t.match(cli.output, `#0 ${script}:2`); + t.match(cli.output, `#1 ${script}:3`); + } }) .then(() => cli.quit()) .then(null, onFatal); diff --git a/deps/node-inspect/test/cli/use-strict.test.js b/deps/node-inspect/test/cli/use-strict.test.js new file mode 100644 index 00000000000000..81f4d91a6a5802 --- /dev/null +++ b/deps/node-inspect/test/cli/use-strict.test.js @@ -0,0 +1,27 @@ +'use strict'; +const Path = require('path'); + +const { test } = require('tap'); + +const startCLI = require('./start-cli'); + +test('for whiles that starts with strict directive', (t) => { + const script = Path.join('examples', 'use-strict.js'); + const cli = startCLI([script]); + + function onFatal(error) { + cli.quit(); + throw error; + } + + return cli.waitFor(/break/) + .then(() => cli.waitForPrompt()) + .then(() => { + t.match( + cli.output, + /break in [^:]+:(?:1|2)[^\d]/, + 'pauses either on strict directive or first "real" line'); + }) + .then(() => cli.quit()) + .then(null, onFatal); +}); diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index f2c738770a43b4..2751bb168981ad 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 5 #define V8_MINOR_VERSION 5 #define V8_BUILD_NUMBER 372 -#define V8_PATCH_LEVEL 41 +#define V8_PATCH_LEVEL 42 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index c2c57b4e587fc5..b8354095c69497 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -7277,7 +7277,11 @@ Local v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) { ENTER_V8(i_isolate); i::Handle obj = i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); - i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length); + // TODO(jbroman): It may be useful in the future to provide a MaybeLocal + // version that throws an exception or otherwise does not crash. + if (!i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length)) { + i::FatalProcessOutOfMemory("v8::ArrayBuffer::New"); + } return Utils::ToLocal(obj); } @@ -7467,8 +7471,12 @@ Local v8::SharedArrayBuffer::New(Isolate* isolate, ENTER_V8(i_isolate); i::Handle obj = i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); - i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true, - i::SharedFlag::kShared); + // TODO(jborman): It may be useful in the future to provide a MaybeLocal + // version that throws an exception or otherwise does not crash. + if (!i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true, + i::SharedFlag::kShared)) { + i::FatalProcessOutOfMemory("v8::SharedArrayBuffer::New"); + } return Utils::ToLocalShared(obj); } diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 19a82a72c803dd..b5c1e9895d1fdc 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -747,6 +747,10 @@ in `list`. This however causes an additional loop to be executed in order to calculate the `totalLength`, so it is faster to provide the length explicitly if it is already known. +If `totalLength` is provided, it is coerced to an unsigned integer. If the +combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is +truncated to `totalLength`. + Example: Create a single `Buffer` from a list of three `Buffer` instances ```js diff --git a/doc/api/cli.md b/doc/api/cli.md index 89879cdc532937..d5d4c4d6188c36 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -94,6 +94,26 @@ Follows `require()`'s module resolution rules. `module` may be either a path to a file, or a node module name. +### `--inspect[=host:port]` + + +Activate inspector on host:port. Default is 127.0.0.1:9229. + +V8 inspector integration allows tools such as Chrome DevTools and IDEs to debug +and profile Node.js instances. The tools attach to Node.js instances via a +tcp port and communicate using the [Chrome Debugging Protocol][]. + + +### `--inspect-brk[=host:port]` + + +Activate inspector on host:port and break at start of user script. + + ### `--no-deprecation` +- `hostname` {string} +- `options` {integer | Object} + - `family` {integer} The record family. Must be `4` or `6`. IPv4 + and IPv6 addresses are both returned by default. + - `hints` {number} One or more [supported `getaddrinfo` flags][]. Multiple + flags may be passed by bitwise `OR`ing their values. + - `all` {boolean} When `true`, the callback returns all resolved addresses in + an array. Otherwise, returns a single address. Defaults to `false`. +- `callback` {Function} + - `err` {Error} + - `address` {string} A string representation of an IPv4 or IPv6 address. + - `family` {integer} `4` or `6`, denoting the family of `address`. Resolves a hostname (e.g. `'nodejs.org'`) into the first found A (IPv4) or -AAAA (IPv6) record. `options` can be an object or integer. If `options` is -not provided, then IPv4 and IPv6 addresses are both valid. If `options` is -an integer, then it must be `4` or `6`. - -Alternatively, `options` can be an object containing these properties: - -* `family` {number} - The record family. If present, must be the integer - `4` or `6`. If not provided, both IP v4 and v6 addresses are accepted. -* `hints`: {number} - If present, it should be one or more of the supported - `getaddrinfo` flags. If `hints` is not provided, then no flags are passed to - `getaddrinfo`. Multiple flags can be passed through `hints` by bitwise - `OR`ing their values. - See [supported `getaddrinfo` flags][] for more information on supported - flags. -* `all`: {boolean} - When `true`, the callback returns all resolved addresses - in an array, otherwise returns a single address. Defaults to `false`. - -All properties are optional. - -The `callback` function has arguments `(err, address, family)`. `address` is a -string representation of an IPv4 or IPv6 address. `family` is either the -integer `4` or `6` and denotes the family of `address` (not necessarily the -value initially passed to `lookup`). - -With the `all` option set to `true`, the arguments change to +AAAA (IPv6) record. All `option` properties are optional. If `options` is an +integer, then it must be `4` or `6` – if `options` is not provided, then IPv4 +and IPv6 addresses are both returned if found. + +With the `all` option set to `true`, the arguments for `callback` change to `(err, addresses)`, with `addresses` being an array of objects with the properties `address` and `family`. @@ -147,6 +139,12 @@ on some operating systems (e.g FreeBSD 10.1). +- `address` {string} +- `port` {number} +- `callback` {Function} + - `err` {Error} + - `hostname` {string} e.g. `example.com` + - `service` {string} e.g. `http` Resolves the given `address` and `port` into a hostname and service using the operating system's underlying `getnameinfo` implementation. @@ -155,10 +153,7 @@ If `address` is not a valid IP address, a `TypeError` will be thrown. The `port` will be coerced to a number. If it is not a legal port, a `TypeError` will be thrown. -The callback has arguments `(err, hostname, service)`. The `hostname` and -`service` arguments are strings (e.g. `'localhost'` and `'http'` respectively). - -On error, `err` is an [`Error`][] object, where `err.code` is the error code. +On an error, `err` is an [`Error`][] object, where `err.code` is the error code. ```js const dns = require('dns'); @@ -172,6 +167,11 @@ dns.lookupService('127.0.0.1', 22, (err, hostname, service) => { +- `hostname` {string} +- `rrtype` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {string[] | Object[] | string[][] | Object} Uses the DNS protocol to resolve a hostname (e.g. `'nodejs.org'`) into an array of the record types specified by `rrtype`. @@ -208,18 +208,21 @@ changes: description: This method now supports passing `options`, specifically `options.ttl`. --> +- `hostname` {string} Hostname to resolve. +- `options` {Object} + - `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record. + When `true`, the callback receives an array of + `{ address: '1.2.3.4', ttl: 60 }` objects rather than an array of strings, + with the TTL expressed in seconds. +- `callback` {Function} + - `err` {Error} + - `addresses` {string[] | Object[]} Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of IPv4 addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`). -* `hostname` {string} Hostname to resolve. -* `options` {Object} - * `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record. - The callback receives an array of `{ address: '1.2.3.4', ttl: 60 }` objects - rather than an array of strings. The TTL is expressed in seconds. -* `callback` {Function} An `(err, result)` callback function. ## dns.resolve6(hostname[, options], callback) +- `hostname` {string} Hostname to resolve. +- `options` {Object} + - `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record. + When `true`, the callback receives an array of + `{ address: '0:1:2:3:4:5:6:7', ttl: 60 }` objects rather than an array of + strings, with the TTL expressed in seconds. +- `callback` {Function} + - `err` {Error} + - `addresses` {string[] | Object[]} Uses the DNS protocol to resolve a IPv6 addresses (`AAAA` records) for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of IPv6 addresses. -* `hostname` {string} Hostname to resolve. -* `options` {Object} - * `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record. - The callback receives an array of `{ address: '0:1:2:3:4:5:6:7', ttl: 60 }` - objects rather than an array of strings. The TTL is expressed in seconds. -* `callback` {Function} An `(err, result)` callback function. ## dns.resolveCname(hostname, callback) +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {string[]} Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The `addresses` argument passed to the `callback` function @@ -256,6 +266,10 @@ will contain an array of canonical name records available for the `hostname` +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {Object[]} Uses the DNS protocol to resolve mail exchange records (`MX` records) for the `hostname`. The `addresses` argument passed to the `callback` function will @@ -266,11 +280,14 @@ property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`). +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {Object[]} Uses the DNS protocol to resolve regular expression based records (`NAPTR` -records) for the `hostname`. The `callback` function has arguments -`(err, addresses)`. The `addresses` argument passed to the `callback` function -will contain an array of objects with the following properties: +records) for the `hostname`. The `addresses` argument passed to the `callback` +function will contain an array of objects with the following properties: * `flags` * `service` @@ -296,16 +313,24 @@ For example: +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {string[]} Uses the DNS protocol to resolve name server records (`NS` records) for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of name server records available for `hostname` (e.g. `['ns1.example.com', 'ns2.example.com']`). -## dns.resolvePtr(hostname, callback) +## dns.resolvePtr(hostname) +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {string[]} Uses the DNS protocol to resolve pointer records (`PTR` records) for the `hostname`. The `addresses` argument passed to the `callback` function will @@ -315,9 +340,13 @@ be an array of strings containing the reply records. +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `address` {Object} Uses the DNS protocol to resolve a start of authority record (`SOA` record) for -the `hostname`. The `addresses` argument passed to the `callback` function will +the `hostname`. The `address` argument passed to the `callback` function will be an object with the following properties: * `nsname` @@ -344,6 +373,10 @@ be an object with the following properties: +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {Object[]} Uses the DNS protocol to resolve service records (`SRV` records) for the `hostname`. The `addresses` argument passed to the `callback` function will @@ -367,6 +400,10 @@ be an array of objects with the following properties: +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {string[][]} Uses the DNS protocol to resolve text queries (`TXT` records) for the `hostname`. The `addresses` argument passed to the `callback` function is @@ -379,13 +416,14 @@ treated separately. +- `ip` {string} +- `callback` {Function} + - `err` {Error} + - `hostnames` {string[]} Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an array of hostnames. -The `callback` function has arguments `(err, hostnames)`, where `hostnames` -is an array of resolved hostnames for the given `ip`. - On error, `err` is an [`Error`][] object, where `err.code` is one of the [DNS error codes][]. @@ -393,11 +431,12 @@ one of the [DNS error codes][]. +- `servers` {string[]} Sets the IP addresses of the servers to be used when resolving. The `servers` argument is an array of IPv4 or IPv6 addresses. -If a port specified on the address it will be removed. +If a port is specified on the address, it will be removed. An error will be thrown if an invalid address is provided. diff --git a/doc/api/events.md b/doc/api/events.md index 5f12cfe3191837..5c0614b68bf2df 100644 --- a/doc/api/events.md +++ b/doc/api/events.md @@ -98,7 +98,7 @@ listener will be invoked _every time_ the named event is emitted. ```js const myEmitter = new MyEmitter(); -var m = 0; +let m = 0; myEmitter.on('event', () => { console.log(++m); }); @@ -114,7 +114,7 @@ the listener is unregistered and *then* called. ```js const myEmitter = new MyEmitter(); -var m = 0; +let m = 0; myEmitter.once('event', () => { console.log(++m); }); @@ -148,7 +148,7 @@ can be used. (_Note, however, that the `domain` module has been deprecated_) const myEmitter = new MyEmitter(); process.on('uncaughtException', (err) => { - console.log('whoops! there was an error'); + console.error('whoops! there was an error'); }); myEmitter.emit('error', new Error('whoops!')); @@ -160,7 +160,7 @@ As a best practice, listeners should always be added for the `'error'` events. ```js const myEmitter = new MyEmitter(); myEmitter.on('error', (err) => { - console.log('whoops! there was an error'); + console.error('whoops! there was an error'); }); myEmitter.emit('error', new Error('whoops!')); // Prints: whoops! there was an error @@ -185,7 +185,7 @@ added and `'removeListener'` when existing listeners are removed. added: v0.1.26 --> -* `eventName` {string|symbol} The name of the event being listened for +* `eventName` {any} The name of the event being listened for * `listener` {Function} The event handler function The `EventEmitter` instance will emit its own `'newListener'` event *before* @@ -229,7 +229,7 @@ changes: now yields the original listener function. --> -* `eventName` {string|symbol} The event name +* `eventName` {any} The event name * `listener` {Function} The event handler function The `'removeListener'` event is emitted *after* the `listener` is removed. @@ -296,6 +296,8 @@ Its `name` property is set to `'MaxListenersExceededWarning'`. +- `eventName` {any} +- `listener` {Function} Alias for `emitter.on(eventName, listener)`. @@ -303,6 +305,8 @@ Alias for `emitter.on(eventName, listener)`. +- `eventName` {any} +- `...args` {any} Synchronously calls each of the listeners registered for the event named `eventName`, in the order they were registered, passing the supplied arguments @@ -345,7 +349,7 @@ set by [`emitter.setMaxListeners(n)`][] or defaults to added: v3.2.0 --> -* `eventName` {string|symbol} The name of the event being listened for +* `eventName` {any} The name of the event being listened for Returns the number of listeners listening to the event named `eventName`. @@ -358,6 +362,7 @@ changes: description: For listeners attached using `.once()` this returns the original listeners instead of wrapper functions now. --> +- `eventName` {any} Returns a copy of the array of listeners for the event named `eventName`. @@ -374,7 +379,7 @@ console.log(util.inspect(server.listeners('connection'))); added: v0.1.101 --> -* `eventName` {string|symbol} The name of the event. +* `eventName` {any} The name of the event. * `listener` {Function} The callback function Adds the `listener` function to the end of the listeners array for the @@ -410,7 +415,7 @@ myEE.emit('foo'); added: v0.3.0 --> -* `eventName` {string|symbol} The name of the event. +* `eventName` {any} The name of the event. * `listener` {Function} The callback function Adds a **one time** `listener` function for the event named `eventName`. The @@ -443,7 +448,7 @@ myEE.emit('foo'); added: v6.0.0 --> -* `eventName` {string|symbol} The name of the event. +* `eventName` {any} The name of the event. * `listener` {Function} The callback function Adds the `listener` function to the *beginning* of the listeners array for the @@ -465,7 +470,7 @@ Returns a reference to the `EventEmitter`, so that calls can be chained. added: v6.0.0 --> -* `eventName` {string|symbol} The name of the event. +* `eventName` {any} The name of the event. * `listener` {Function} The callback function Adds a **one time** `listener` function for the event named `eventName` to the @@ -484,6 +489,7 @@ Returns a reference to the `EventEmitter`, so that calls can be chained. +- `eventName` {any} Removes all listeners, or those of the specified `eventName`. @@ -497,12 +503,14 @@ Returns a reference to the `EventEmitter`, so that calls can be chained. +- `eventName` {any} +- `listener` {Function} Removes the specified `listener` from the listener array for the event named `eventName`. ```js -var callback = (stream) => { +const callback = (stream) => { console.log('someone connected!'); }; server.on('connection', callback); @@ -524,12 +532,12 @@ events will behave as expected. ```js const myEmitter = new MyEmitter(); -var callbackA = () => { +const callbackA = () => { console.log('A'); myEmitter.removeListener('event', callbackB); }; -var callbackB = () => { +const callbackB = () => { console.log('B'); }; @@ -564,6 +572,7 @@ Returns a reference to the `EventEmitter`, so that calls can be chained. +- `n` {integer} By default EventEmitters will print a warning if more than `10` listeners are added for a particular event. This is a useful default that helps finding diff --git a/doc/api/process.md b/doc/api/process.md index ff70f81244afc7..f158a1bc8efa14 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -298,7 +298,7 @@ too many listeners have been added to an event ```txt $ node -> event.defaultMaxListeners = 1; +> events.defaultMaxListeners = 1; > process.on('foo', () => {}); > process.on('foo', () => {}); > (node:38638) Warning: Possible EventEmitter memory leak detected. 2 foo @@ -311,7 +311,7 @@ adds a custom handler to the `'warning'` event: ```txt $ node --no-warnings > var p = process.on('warning', (warning) => console.warn('Do not do that!')); -> event.defaultMaxListeners = 1; +> events.defaultMaxListeners = 1; > process.on('foo', () => {}); > process.on('foo', () => {}); > Do not do that! diff --git a/doc/api/stream.md b/doc/api/stream.md index c48dfe050808ee..289250c638ff15 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -981,7 +981,7 @@ setTimeout(() => { added: v0.9.11 --> -* `chunk` {Buffer|string} Chunk of data to unshift onto the read queue +* `chunk` {Buffer|string|any} Chunk of data to unshift onto the read queue The `readable.unshift()` method pushes a chunk of data back into the internal buffer. This is useful in certain situations where a stream is being consumed by @@ -1016,7 +1016,7 @@ function parseHeader(stream, callback) { const remaining = split.join('\n\n'); const buf = Buffer.from(remaining, 'utf8'); stream.removeListener('error', callback); - // set the readable listener before unshifting + // remove the readable listener before unshifting stream.removeListener('readable', onReadable); if (buf.length) stream.unshift(buf); @@ -1295,8 +1295,9 @@ const myWritable = new Writable({ #### writable.\_write(chunk, encoding, callback) -* `chunk` {Buffer|string} The chunk to be written. Will **always** - be a buffer unless the `decodeStrings` option was set to `false`. +* `chunk` {Buffer|string|any} The chunk to be written. Will **always** + be a buffer unless the `decodeStrings` option was set to `false` + or the stream is operating in object mode. * `encoding` {string} If the chunk is a string, then `encoding` is the character encoding of that string. If chunk is a `Buffer`, or if the stream is operating in object mode, `encoding` may be ignored. @@ -1500,13 +1501,13 @@ user programs. #### readable.push(chunk[, encoding]) -* `chunk` {Buffer|null|string} Chunk of data to push into the read queue +* `chunk` {Buffer|null|string|any} Chunk of data to push into the read queue * `encoding` {string} Encoding of String chunks. Must be a valid Buffer encoding, such as `'utf8'` or `'ascii'` * Returns {boolean} `true` if additional chunks of data may continued to be pushed; `false` otherwise. -When `chunk` is a `Buffer` or `string`, the `chunk` of data will be added to the +When `chunk` is not `null`, the `chunk` of data will be added to the internal queue for users of the stream to consume. Passing `chunk` as `null` signals the end of the stream (EOF), after which no more data can be written. @@ -1873,8 +1874,9 @@ user programs. #### transform.\_transform(chunk, encoding, callback) -* `chunk` {Buffer|string} The chunk to be transformed. Will **always** - be a buffer unless the `decodeStrings` option was set to `false`. +* `chunk` {Buffer|string|any} The chunk to be transformed. Will **always** + be a buffer unless the `decodeStrings` option was set to `false` + or the stream is operating in object mode. * `encoding` {string} If the chunk is a string, then this is the encoding type. If chunk is a buffer, then this is the special value - 'buffer', ignore it in this case. diff --git a/doc/api/vm.md b/doc/api/vm.md index 025e9725a94e66..b6fb90440a1993 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -14,6 +14,9 @@ const vm = require('vm'); JavaScript code can be compiled and run immediately or compiled, saved, and run later. +*Note*: The vm module is not a security mechanism. +**Do not use it to run untrusted code**. + ## Class: vm.Script