diff --git a/common.gypi b/common.gypi index b23898301a4898..4dfbdfac061887 100644 --- a/common.gypi +++ b/common.gypi @@ -35,7 +35,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.13', + 'v8_embedder_string': '-node.14', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/include/v8-internal.h b/deps/v8/include/v8-internal.h index 876408ebba98f9..52ee403f526d06 100644 --- a/deps/v8/include/v8-internal.h +++ b/deps/v8/include/v8-internal.h @@ -106,6 +106,10 @@ const int kApiTaggedSize = kApiInt32Size; const int kApiTaggedSize = kApiSystemPointerSize; #endif +constexpr bool PointerCompressionIsEnabled() { + return kApiTaggedSize != kApiSystemPointerSize; +} + #ifdef V8_31BIT_SMIS_ON_64BIT_ARCH using PlatformSmiTagging = SmiTagging; #else diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index 13724930103db1..9a58ef8720c4b4 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -9530,7 +9530,12 @@ class V8_EXPORT V8 { * Initializes V8. This function needs to be called before the first Isolate * is created. It always returns true. */ - static bool Initialize(); + V8_INLINE static bool Initialize() { + const int kBuildConfiguration = + (internal::PointerCompressionIsEnabled() ? kPointerCompression : 0) | + (internal::SmiValuesAre31Bits() ? k31BitSmis : 0); + return Initialize(kBuildConfiguration); + } /** * Allows the host application to provide a callback which can be used @@ -9664,6 +9669,17 @@ class V8_EXPORT V8 { private: V8(); + enum BuildConfigurationFeatures { + kPointerCompression = 1 << 0, + k31BitSmis = 1 << 1, + }; + + /** + * Checks that the embedder build configuration is compatible with + * the V8 binary and if so initializes V8. + */ + static bool Initialize(int build_config); + static internal::Address* GlobalizeReference(internal::Isolate* isolate, internal::Address* handle); static internal::Address* GlobalizeTracedReference(internal::Isolate* isolate, diff --git a/deps/v8/src/api/api.cc b/deps/v8/src/api/api.cc index 7fe974de24e8db..dac9e97b1ba121 100644 --- a/deps/v8/src/api/api.cc +++ b/deps/v8/src/api/api.cc @@ -5652,7 +5652,25 @@ void v8::V8::InitializePlatform(Platform* platform) { void v8::V8::ShutdownPlatform() { i::V8::ShutdownPlatform(); } -bool v8::V8::Initialize() { +bool v8::V8::Initialize(const int build_config) { + const bool kEmbedderPointerCompression = + (build_config & kPointerCompression) != 0; + if (kEmbedderPointerCompression != COMPRESS_POINTERS_BOOL) { + FATAL( + "Embedder-vs-V8 build configuration mismatch. On embedder side " + "pointer compression is %s while on V8 side it's %s.", + kEmbedderPointerCompression ? "ENABLED" : "DISABLED", + COMPRESS_POINTERS_BOOL ? "ENABLED" : "DISABLED"); + } + + const int kEmbedderSmiValueSize = (build_config & k31BitSmis) ? 31 : 32; + if (kEmbedderSmiValueSize != internal::kSmiValueSize) { + FATAL( + "Embedder-vs-V8 build configuration mismatch. On embedder side " + "Smi value size is %d while on V8 side it's %d.", + kEmbedderSmiValueSize, internal::kSmiValueSize); + } + i::V8::Initialize(); return true; }