From 4c0a7d845ecf98d0af7552ed511d8352a01abb46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Fri, 29 Sep 2017 13:39:26 +0200 Subject: [PATCH] build: add V8 embedder version string After this commit, `process.versions.v8` will look like: "6.0.287.53-node.0". The goal is that everytime we apply a non-official patch to `deps/v8`, we increment our own number instead of V8's patch level. This number must be set back to 0 after major V8 updates. Closes: https://github.com/nodejs/node/issues/15698 --- common.gypi | 4 ++++ doc/api/process.md | 5 ++++- lib/internal/v8_prof_polyfill.js | 12 +++++++----- test/parallel/test-process-versions.js | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/common.gypi b/common.gypi index 6677274f3abe80..04147948287a94 100644 --- a/common.gypi +++ b/common.gypi @@ -25,6 +25,10 @@ # Default to -O0 for debug builds. 'v8_optimized_debug%': 0, + # 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.0', + # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/doc/api/process.md b/doc/api/process.md index 8b8ce0f43dd0d2..ca5f13ed5615c5 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -1790,6 +1790,9 @@ changes: - version: v4.2.0 pr-url: https://github.com/nodejs/node/pull/3102 description: The `icu` property is now supported. + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/15785 + description: The `v8` property now includes a Node.js specific suffix. --> * {Object} @@ -1810,7 +1813,7 @@ Will generate an object similar to: { http_parser: '2.3.0', node: '1.1.1', - v8: '4.1.0.14', + v8: '6.1.534.42-node.0', uv: '1.3.0', zlib: '1.2.8', ares: '1.10.0-DEV', diff --git a/lib/internal/v8_prof_polyfill.js b/lib/internal/v8_prof_polyfill.js index e77f1f76bcb9ee..1c9ba4ebc546fc 100644 --- a/lib/internal/v8_prof_polyfill.js +++ b/lib/internal/v8_prof_polyfill.js @@ -82,14 +82,16 @@ function readline() { } function versionCheck() { - // v8-version looks like "v8-version,$major,$minor,$build,$patch,$candidate" - // whereas process.versions.v8 is either "$major.$minor.$build" or - // "$major.$minor.$build.$patch". + // v8-version looks like + // "v8-version,$major,$minor,$build,$patch[,$embedder],$candidate" + // whereas process.versions.v8 is either "$major.$minor.$build-$embedder" or + // "$major.$minor.$build.$patch-$embedder". var firstLine = readline(); line = firstLine + '\n' + line; firstLine = firstLine.split(','); - const curVer = process.versions.v8.split('.'); - if (firstLine.length !== 6 && firstLine[0] !== 'v8-version') { + const curVer = process.versions.v8.split(/\.-/); + if (firstLine.length !== 6 && firstLine.length !== 7 || + firstLine[0] !== 'v8-version') { console.log('Unable to read v8-version from log file.'); return; } diff --git a/test/parallel/test-process-versions.js b/test/parallel/test-process-versions.js index 65634ece6ce8e7..5644ac4658b534 100644 --- a/test/parallel/test-process-versions.js +++ b/test/parallel/test-process-versions.js @@ -29,7 +29,7 @@ assert(commonTemplate.test(process.versions.node)); assert(commonTemplate.test(process.versions.uv)); assert(commonTemplate.test(process.versions.zlib)); -assert(/^\d+\.\d+\.\d+(?:\.\d+)?(?: \(candidate\))?$/ +assert(/^\d+\.\d+\.\d+(?:\.\d+)?-node\.\d+(?: \(candidate\))?$/ .test(process.versions.v8)); assert(/^\d+$/.test(process.versions.modules));