deps: V8: cherry-pick 99ebeac9c548

Original commit message:

    [torque] Fix C++ object layout assertions for MSVC STL

    The assertions generated for @cppObjectLayoutDefinition classes assume
    that the first field of a derived class starts at sizeof(Parent) and
    that sizeof(Class) == the packed size computed by Torque. Both
    assumptions break when compiling with the MSVC STL, which stores
    std::atomic<T> with alignas(sizeof(T)). Under the Microsoft C++ ABI an
    alignas() is a required alignment that #pragma pack cannot lower, so the
    std::atomic bit fields of Map force Map, and in turn the pack(1)
    ExtendedMap, to align by 4 bytes. After rounding up,

    sizeof(ExtendedMap) == sizeof(Map) + 4 == kSize + 3

    so

    static_assert(kSize == sizeof(ExtendedMap))

    fails. The base subobject size is not rounded up
    however, so JSInterceptorMap places its first field at sizeof(Map) + 1
    rather than sizeof(ExtendedMap), and

    static_assert(kFlagsOffset == offsetof(JSInterceptorMap, flags_))

    fails as well.

    Fix this by:

    - Using the packed parent size that Torque already knows as the offset
      of the first derived field instead of sizeof(Parent).
    - Relaxing the assertion to only require that sizeof(Class) does not
      exceed kSize by alignof(Class) or more, so that any extra bytes fit
      into the alignment padding.

    Co-Authored-By: StefanStojanovic <stefan.stojanovic@janeasystems.com>
    Refs: https://github.com/nodejs/node/pull/65161
    Bug: 531344950
    Change-Id: I16811484a8ff3d1bff187bab950ac71b6ea7f297
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/8486028
    Reviewed-by: Leszek Swirski <leszeks@chromium.org>
    Reviewed-by: Igor Sheludko <ishell@chromium.org>
    Commit-Queue: Joyee Cheung <joyee@igalia.com>
    Cr-Commit-Position: refs/heads/main@{#110223}

Refs: https://github.com/v8/v8/commit/99ebeac9c548e36f9e18658097df0b6c42b1c71c
Co-Authored-By: StefanStojanovic <stefan.stojanovic@janeasystems.com>
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65161
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
This commit is contained in:
Joyee CheungandStefanStojanovic authored and Antoine du Hamel committed 2026-10-04 22:39:13 +02:00
1 parent c419eaca14
commit 33e5031503
2 files changed
+8 -2

No files matched your search

+1 -1
View File
@@ -44,7 +44,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.11',
'v8_embedder_string': '-node.12',
##### V8 defaults for Node.js #####
+7 -1
View File
@@ -4023,6 +4023,11 @@ class ClassFieldOffsetGenerator : public FieldOffsetsGenerator {
std::string parent_name = use_templates ? "P" : parent->name();
if (type->IsLayoutDefinedInCpp()) {
if (parent) {
if (std::optional<size_t> packed_size = parent->size().SingleValue()) {
return std::to_string(*packed_size);
}
}
return "sizeof(" + parent_name + ")";
}
@@ -4111,7 +4116,8 @@ void CppClassGenerator::GenerateCppObjectLayoutDefinitionAsserts() {
<< "::" << f.name_and_type.name << " in C++ do not match\");\n";
}
if (!type_->IsAbstract() && type_->HasStaticSize()) {
impl_ << " static_assert(kSize == sizeof(" + name_ + "));\n";
impl_ << " static_assert(kSize <= sizeof(" + name_ + ") && sizeof(" +
name_ + ") < kSize + alignof(" + name_ + "));\n";
}
impl_ << "};\n\n";