Skip to content

Commit 2bc79f5

Browse files
addaleaxtargos
authored andcommitted
deps: V8: cherry-pick 2db93c023379
Original commit message: [api] Add embedder-vs-V8 build configuration compatibility check v8::V8::Initialize() will fail with meaningful error upon build configuration mismatch. Bug: v8:10041 Change-Id: Ic69ba68ef1764b356beef0f204fe58b45bae3c49 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2144953 Commit-Queue: Igor Sheludko <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Cr-Commit-Position: refs/heads/master@{#67116} Refs: v8/v8@2db93c0 Backport-PR-URL: #33376 PR-URL: #32885 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Beth Griggs <[email protected]>
1 parent b6da777 commit 2bc79f5

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.13',
39+
'v8_embedder_string': '-node.14',
4040

4141
##### V8 defaults for Node.js #####
4242

deps/v8/include/v8-internal.h

+4
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ const int kApiTaggedSize = kApiInt32Size;
106106
const int kApiTaggedSize = kApiSystemPointerSize;
107107
#endif
108108

109+
constexpr bool PointerCompressionIsEnabled() {
110+
return kApiTaggedSize != kApiSystemPointerSize;
111+
}
112+
109113
#ifdef V8_31BIT_SMIS_ON_64BIT_ARCH
110114
using PlatformSmiTagging = SmiTagging<kApiInt32Size>;
111115
#else

deps/v8/include/v8.h

+17-1
Original file line numberDiff line numberDiff line change
@@ -9598,7 +9598,12 @@ class V8_EXPORT V8 {
95989598
* Initializes V8. This function needs to be called before the first Isolate
95999599
* is created. It always returns true.
96009600
*/
9601-
static bool Initialize();
9601+
V8_INLINE static bool Initialize() {
9602+
const int kBuildConfiguration =
9603+
(internal::PointerCompressionIsEnabled() ? kPointerCompression : 0) |
9604+
(internal::SmiValuesAre31Bits() ? k31BitSmis : 0);
9605+
return Initialize(kBuildConfiguration);
9606+
}
96029607

96039608
/**
96049609
* Allows the host application to provide a callback which can be used
@@ -9732,6 +9737,17 @@ class V8_EXPORT V8 {
97329737
private:
97339738
V8();
97349739

9740+
enum BuildConfigurationFeatures {
9741+
kPointerCompression = 1 << 0,
9742+
k31BitSmis = 1 << 1,
9743+
};
9744+
9745+
/**
9746+
* Checks that the embedder build configuration is compatible with
9747+
* the V8 binary and if so initializes V8.
9748+
*/
9749+
static bool Initialize(int build_config);
9750+
97359751
static internal::Address* GlobalizeReference(internal::Isolate* isolate,
97369752
internal::Address* handle);
97379753
static internal::Address* GlobalizeTracedReference(internal::Isolate* isolate,

deps/v8/src/api/api.cc

+19-1
Original file line numberDiff line numberDiff line change
@@ -5721,7 +5721,25 @@ void v8::V8::InitializePlatform(Platform* platform) {
57215721

57225722
void v8::V8::ShutdownPlatform() { i::V8::ShutdownPlatform(); }
57235723

5724-
bool v8::V8::Initialize() {
5724+
bool v8::V8::Initialize(const int build_config) {
5725+
const bool kEmbedderPointerCompression =
5726+
(build_config & kPointerCompression) != 0;
5727+
if (kEmbedderPointerCompression != COMPRESS_POINTERS_BOOL) {
5728+
FATAL(
5729+
"Embedder-vs-V8 build configuration mismatch. On embedder side "
5730+
"pointer compression is %s while on V8 side it's %s.",
5731+
kEmbedderPointerCompression ? "ENABLED" : "DISABLED",
5732+
COMPRESS_POINTERS_BOOL ? "ENABLED" : "DISABLED");
5733+
}
5734+
5735+
const int kEmbedderSmiValueSize = (build_config & k31BitSmis) ? 31 : 32;
5736+
if (kEmbedderSmiValueSize != internal::kSmiValueSize) {
5737+
FATAL(
5738+
"Embedder-vs-V8 build configuration mismatch. On embedder side "
5739+
"Smi value size is %d while on V8 side it's %d.",
5740+
kEmbedderSmiValueSize, internal::kSmiValueSize);
5741+
}
5742+
57255743
i::V8::Initialize();
57265744
return true;
57275745
}

0 commit comments

Comments
 (0)