Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: introduce embedder version number for V8 #9754

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

'openssl_fips%': '',

'v8_embedder_string': '.node.0',

# Default to -O0 for debug builds.
'v8_optimized_debug%': 0,

Expand Down
5 changes: 5 additions & 0 deletions deps/v8/gypfiles/features.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
# Enable compiler warnings when using V8_DEPRECATE_SOON apis.
'v8_imminent_deprecation_warnings%': 0,

'v8_embedder_string%': '',

# Set to 1 to enable DCHECKs in release builds.
'dcheck_always_on%': 0,

Expand Down Expand Up @@ -105,6 +107,9 @@
['v8_use_snapshot=="true" and v8_use_external_startup_data==1', {
'defines': ['V8_USE_EXTERNAL_STARTUP_DATA',],
}],
['v8_embedder_string', {
'defines': ['V8_EMBEDDER_STRING="<(v8_embedder_string)"',],
}],
['dcheck_always_on!=0', {
'defines': ['DEBUG',],
}],
Expand Down
4 changes: 4 additions & 0 deletions deps/v8/include/v8-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#define V8_BUILD_NUMBER 500
#define V8_PATCH_LEVEL 44

#ifndef V8_EMBEDDER_STRING
#define V8_EMBEDDER_STRING ""
#endif // V8_EMBEDDER_STRING

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
#define V8_IS_CANDIDATE_VERSION 0
Expand Down
14 changes: 11 additions & 3 deletions deps/v8/src/log-utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,17 @@ void Log::Initialize(const char* log_file_name) {

if (output_handle_ != nullptr) {
Log::MessageBuilder msg(this);
msg.Append("v8-version,%d,%d,%d,%d,%d", Version::GetMajor(),
Version::GetMinor(), Version::GetBuild(), Version::GetPatch(),
Version::IsCandidate());
if (strlen(Version::GetEmbedder()) == 0) {
msg.Append("v8-version,%d,%d,%d,%d,%d",
Version::GetMajor(), Version::GetMinor(),
Version::GetBuild(), Version::GetPatch(),
Version::IsCandidate());
} else {
msg.Append("v8-version,%d,%d,%d,%d,%s,%d",
Version::GetMajor(), Version::GetMinor(),
Version::GetBuild(), Version::GetPatch(),
Version::GetEmbedder(), Version::IsCandidate());
}
msg.WriteToLogFile();
}
}
Expand Down
14 changes: 8 additions & 6 deletions deps/v8/src/version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#if V8_PATCH_LEVEL > 0
#define VERSION_STRING \
S(V8_MAJOR_VERSION) "." S(V8_MINOR_VERSION) "." S(V8_BUILD_NUMBER) "." S( \
V8_PATCH_LEVEL) CANDIDATE_STRING
V8_PATCH_LEVEL) V8_EMBEDDER_STRING CANDIDATE_STRING
#else
#define VERSION_STRING \
S(V8_MAJOR_VERSION) "." S(V8_MINOR_VERSION) "." S(V8_BUILD_NUMBER) \
Expand All @@ -38,6 +38,7 @@ int Version::major_ = V8_MAJOR_VERSION;
int Version::minor_ = V8_MINOR_VERSION;
int Version::build_ = V8_BUILD_NUMBER;
int Version::patch_ = V8_PATCH_LEVEL;
const char* Version::embedder_ = V8_EMBEDDER_STRING;
bool Version::candidate_ = (V8_IS_CANDIDATE_VERSION != 0);
const char* Version::soname_ = SONAME;
const char* Version::version_string_ = VERSION_STRING;
Expand All @@ -51,9 +52,9 @@ void Version::GetString(Vector<char> str) {
const char* is_simulator = "";
#endif // USE_SIMULATOR
if (GetPatch() > 0) {
SNPrintF(str, "%d.%d.%d.%d%s%s",
GetMajor(), GetMinor(), GetBuild(), GetPatch(), candidate,
is_simulator);
SNPrintF(str, "%d.%d.%d.%d%s%s%s",
GetMajor(), GetMinor(), GetBuild(), GetPatch(), GetEmbedder(),
candidate, is_simulator);
} else {
SNPrintF(str, "%d.%d.%d%s%s",
GetMajor(), GetMinor(), GetBuild(), candidate,
Expand All @@ -68,8 +69,9 @@ void Version::GetSONAME(Vector<char> str) {
// Generate generic SONAME if no specific SONAME is defined.
const char* candidate = IsCandidate() ? "-candidate" : "";
if (GetPatch() > 0) {
SNPrintF(str, "libv8-%d.%d.%d.%d%s.so",
GetMajor(), GetMinor(), GetBuild(), GetPatch(), candidate);
SNPrintF(str, "libv8-%d.%d.%d.%d%s%s.so",
GetMajor(), GetMinor(), GetBuild(), GetPatch(), GetEmbedder(),
candidate);
} else {
SNPrintF(str, "libv8-%d.%d.%d%s.so",
GetMajor(), GetMinor(), GetBuild(), candidate);
Expand Down
5 changes: 4 additions & 1 deletion deps/v8/src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Version {
static int GetMinor() { return minor_; }
static int GetBuild() { return build_; }
static int GetPatch() { return patch_; }
static const char* GetEmbedder() { return embedder_; }
static bool IsCandidate() { return candidate_; }
static uint32_t Hash() {
return static_cast<uint32_t>(
Expand All @@ -38,13 +39,15 @@ class Version {
static int minor_;
static int build_;
static int patch_;
static const char* embedder_;
static bool candidate_;
static const char* soname_;
static const char* version_string_;

// In test-version.cc.
friend void SetVersion(int major, int minor, int build, int patch,
bool candidate, const char* soname);
const char* embedder, bool candidate,
const char* soname);
};

} // namespace internal
Expand Down
59 changes: 36 additions & 23 deletions deps/v8/test/cctest/test-version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ namespace v8 {
namespace internal {

void SetVersion(int major, int minor, int build, int patch,
bool candidate, const char* soname) {
const char* embedder, bool candidate,
const char* soname) {
Version::major_ = major;
Version::minor_ = minor;
Version::build_ = build;
Version::patch_ = patch;
Version::embedder_ = embedder;
Version::candidate_ = candidate;
Version::soname_ = soname;
}
Expand All @@ -51,22 +53,22 @@ void SetVersion(int major, int minor, int build, int patch,


static void CheckVersion(int major, int minor, int build,
int patch, bool candidate,
int patch, const char* embedder, bool candidate,
const char* expected_version_string,
const char* expected_generic_soname) {
static v8::internal::EmbeddedVector<char, 128> version_str;
static v8::internal::EmbeddedVector<char, 128> soname_str;

// Test version without specific SONAME.
SetVersion(major, minor, build, patch, candidate, "");
SetVersion(major, minor, build, patch, embedder, candidate, "");
Version::GetString(version_str);
CHECK_EQ(0, strcmp(expected_version_string, version_str.start()));
Version::GetSONAME(soname_str);
CHECK_EQ(0, strcmp(expected_generic_soname, soname_str.start()));

// Test version with specific SONAME.
const char* soname = "libv8.so.1";
SetVersion(major, minor, build, patch, candidate, soname);
SetVersion(major, minor, build, patch, embedder, candidate, soname);
Version::GetString(version_str);
CHECK_EQ(0, strcmp(expected_version_string, version_str.start()));
Version::GetSONAME(soname_str);
Expand All @@ -76,30 +78,41 @@ static void CheckVersion(int major, int minor, int build,

TEST(VersionString) {
#ifdef USE_SIMULATOR
CheckVersion(0, 0, 0, 0, false, "0.0.0 SIMULATOR", "libv8-0.0.0.so");
CheckVersion(0, 0, 0, 0, true,
CheckVersion(0, 0, 0, 0, "", false, "0.0.0 SIMULATOR", "libv8-0.0.0.so");
CheckVersion(0, 0, 0, 0, "", true,
"0.0.0 (candidate) SIMULATOR", "libv8-0.0.0-candidate.so");
CheckVersion(1, 0, 0, 0, false, "1.0.0 SIMULATOR", "libv8-1.0.0.so");
CheckVersion(1, 0, 0, 0, true,
CheckVersion(1, 0, 0, 0, "", false, "1.0.0 SIMULATOR", "libv8-1.0.0.so");
CheckVersion(1, 0, 0, 0, "", true,
"1.0.0 (candidate) SIMULATOR", "libv8-1.0.0-candidate.so");
CheckVersion(1, 0, 0, 1, false, "1.0.0.1 SIMULATOR", "libv8-1.0.0.1.so");
CheckVersion(1, 0, 0, 1, true,
"1.0.0.1 (candidate) SIMULATOR", "libv8-1.0.0.1-candidate.so");
CheckVersion(2, 5, 10, 7, false, "2.5.10.7 SIMULATOR", "libv8-2.5.10.7.so");
CheckVersion(2, 5, 10, 7, true,
"2.5.10.7 (candidate) SIMULATOR", "libv8-2.5.10.7-candidate.so");
CheckVersion(1, 0, 0, 1, "", false,
"1.0.0.1 SIMULATOR", "libv8-1.0.0.1.so");
CheckVersion(1, 0, 0, 1, "", true, "1.0.0.1 (candidate) SIMULATOR",
"libv8-1.0.0.1-candidate.so");
CheckVersion(2, 5, 10, 7, "", false,
"2.5.10.7 SIMULATOR", "libv8-2.5.10.7.so");
CheckVersion(2, 5, 10, 7, "", true, "2.5.10.7 (candidate) SIMULATOR",
"libv8-2.5.10.7.0-candidate.so");
CheckVersion(2, 5, 10, 7, ".emb.1", false,
"2.5.10.7.emb.1 SIMULATOR", "libv8-2.5.10.7.emb.1.so");
CheckVersion(2, 5, 10, 7, ".emb.1", true,
"2.5.10.7.emb.1 (candidate) SIMULATOR",
"libv8-2.5.10.7.emb.1-candidate.so");
#else
CheckVersion(0, 0, 0, 0, false, "0.0.0", "libv8-0.0.0.so");
CheckVersion(0, 0, 0, 0, true,
CheckVersion(0, 0, 0, 0, "", false, "0.0.0", "libv8-0.0.0.so");
CheckVersion(0, 0, 0, 0, "", true,
"0.0.0 (candidate)", "libv8-0.0.0-candidate.so");
CheckVersion(1, 0, 0, 0, false, "1.0.0", "libv8-1.0.0.so");
CheckVersion(1, 0, 0, 0, true,
CheckVersion(1, 0, 0, 0, "", false, "1.0.0", "libv8-1.0.0.so");
CheckVersion(1, 0, 0, 0, "", true,
"1.0.0 (candidate)", "libv8-1.0.0-candidate.so");
CheckVersion(1, 0, 0, 1, false, "1.0.0.1", "libv8-1.0.0.1.so");
CheckVersion(1, 0, 0, 1, true,
"1.0.0.1 (candidate)", "libv8-1.0.0.1-candidate.so");
CheckVersion(2, 5, 10, 7, false, "2.5.10.7", "libv8-2.5.10.7.so");
CheckVersion(2, 5, 10, 7, true,
CheckVersion(1, 0, 0, 1, "", false, "1.0.0.1", "libv8-1.0.0.1.so");
CheckVersion(1, 0, 0, 1, "", true,
"1.0.0.1.0 (candidate)", "libv8-1.0.0.1-candidate.so");
CheckVersion(2, 5, 10, 7, "", false, "2.5.10.7", "libv8-2.5.10.7.so");
CheckVersion(2, 5, 10, 7, "", true,
"2.5.10.7 (candidate)", "libv8-2.5.10.7-candidate.so");
CheckVersion(2, 5, 10, 7, ".emb.1", false, "2.5.10.7.emb.1",
"libv8-2.5.10.7.emb.1.so");
CheckVersion(2, 5, 10, 7, ".emb.1", true, "2.5.10.7.emb.1 (candidate)",
"libv8-2.5.10.7.emb.1-candidate.so");
#endif
}
6 changes: 4 additions & 2 deletions lib/internal/v8_prof_polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ function readline() {
}

function versionCheck() {
// v8-version looks like "v8-version,$major,$minor,$build,$patch,$candidate"
// v8-version looks like
// "v8-version,$major,$minor,$build,$patch[,$embedder],$candidate"
// whereas process.versions.v8 is either "$major.$minor.$build" or
// "$major.$minor.$build.$patch".
var firstLine = readline();
line = firstLine + '\n' + line;
firstLine = firstLine.split(',');
const curVer = process.versions.v8.split('.');
if (firstLine.length !== 6 && firstLine[0] !== 'v8-version') {
if (firstLine.length !== 6 && firstLine.length !== 7 ||
firstLine[0] !== 'v8-version') {
console.log('Unable to read v8-version from log file.');
return;
}
Expand Down