From 678641f470e64b42b3c0bc45270d0561ebb3c269 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Tue, 2 Apr 2024 22:55:25 +0100 Subject: [PATCH] deps: V8: cherry-pick d15d49b09dc7 Original commit message: Make bitfields only as wide as necessary for enums clang now complains when a BitField for an enum is too wide. We could suppress this, but it seems kind of useful from an uninformed distance, so I made a few bitfields smaller instead. (For AddressingMode, since its size is target-dependent, I added an explicit underlying type to the enum instead, which suppresses the diag on a per-enum basis.) This is without any understanding of the code I'm touching. Especially the change in v8-internal.h feels a bit risky to me. Bug: chromium:1348574 Change-Id: I73395de593045036b72dadf4e3147b5f7e13c958 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3794708 Commit-Queue: Nico Weber Reviewed-by: Leszek Swirski Reviewed-by: Hannes Payer Auto-Submit: Nico Weber Cr-Commit-Position: refs/heads/main@{#82109} Refs: https://github.com/v8/v8/commit/d15d49b09dc7aef9edcc4cf6a0cb2b77a0db203f PR-URL: https://github.com/nodejs/node/pull/52337 Fixes: https://github.com/nodejs/node/issues/52230 Reviewed-By: Rafael Gonzaga --- common.gypi | 2 +- deps/v8/src/ast/ast.h | 2 +- deps/v8/src/base/bit-field.h | 5 +++++ deps/v8/src/compiler/backend/instruction-codes.h | 4 ++-- deps/v8/src/compiler/backend/instruction.h | 4 ++-- deps/v8/src/maglev/maglev-ir.h | 2 +- deps/v8/src/wasm/wasm-code-manager.h | 2 +- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/common.gypi b/common.gypi index 38471d4639eb5e..ec92c9df4c1ea2 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,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.36', + 'v8_embedder_string': '-node.37', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/ast/ast.h b/deps/v8/src/ast/ast.h index 971a2b0ec1321e..be1fe09ee438ad 100644 --- a/deps/v8/src/ast/ast.h +++ b/deps/v8/src/ast/ast.h @@ -999,7 +999,7 @@ class Literal final : public Expression { friend class AstNodeFactory; friend Zone; - using TypeField = Expression::NextBitField; + using TypeField = Expression::NextBitField; Literal(int smi, int position) : Expression(position, kLiteral), smi_(smi) { bit_field_ = TypeField::update(bit_field_, kSmi); diff --git a/deps/v8/src/base/bit-field.h b/deps/v8/src/base/bit-field.h index 63142a20fa2c29..9605c41c14f8ce 100644 --- a/deps/v8/src/base/bit-field.h +++ b/deps/v8/src/base/bit-field.h @@ -40,6 +40,11 @@ class BitField final { static constexpr U kNumValues = U{1} << kSize; // Value for the field with all bits set. + // If clang complains + // "constexpr variable 'kMax' must be initialized by a constant expression" + // on this line, then you're creating a BitField for an enum with more bits + // than needed for the enum values. Either reduce the BitField size, + // or give the enum an explicit underlying type. static constexpr T kMax = static_cast(kNumValues - 1); template diff --git a/deps/v8/src/compiler/backend/instruction-codes.h b/deps/v8/src/compiler/backend/instruction-codes.h index b06b522287f2d1..19cb21d041b897 100644 --- a/deps/v8/src/compiler/backend/instruction-codes.h +++ b/deps/v8/src/compiler/backend/instruction-codes.h @@ -195,7 +195,7 @@ V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, V(None) \ TARGET_ADDRESSING_MODE_LIST(V) -enum AddressingMode { +enum AddressingMode : uint8_t { #define DECLARE_ADDRESSING_MODE(Name) kMode_##Name, ADDRESSING_MODE_LIST(DECLARE_ADDRESSING_MODE) #undef DECLARE_ADDRESSING_MODE @@ -306,7 +306,7 @@ using MiscField = base::BitField; // LaneSizeField and AccessModeField are helper types to encode/decode a lane // size, an access mode, or both inside the overlapping MiscField. using LaneSizeField = base::BitField; -using AccessModeField = base::BitField; +using AccessModeField = base::BitField; // TODO(turbofan): {HasMemoryAccessMode} is currently only used to guard // decoding (in CodeGenerator and InstructionScheduler). Encoding (in // InstructionSelector) is not yet guarded. There are in fact instructions for diff --git a/deps/v8/src/compiler/backend/instruction.h b/deps/v8/src/compiler/backend/instruction.h index 89394b2c2427d3..66a6232c32a8d0 100644 --- a/deps/v8/src/compiler/backend/instruction.h +++ b/deps/v8/src/compiler/backend/instruction.h @@ -586,8 +586,8 @@ class LocationOperand : public InstructionOperand { } STATIC_ASSERT(KindField::kSize == 3); - using LocationKindField = base::BitField64; - using RepresentationField = base::BitField64; + using LocationKindField = base::BitField64; + using RepresentationField = LocationKindField::Next; using IndexField = base::BitField64; }; diff --git a/deps/v8/src/maglev/maglev-ir.h b/deps/v8/src/maglev/maglev-ir.h index 1f7c5471de025d..9ff1a3085790c8 100644 --- a/deps/v8/src/maglev/maglev-ir.h +++ b/deps/v8/src/maglev/maglev-ir.h @@ -196,7 +196,7 @@ class OpProperties { } constexpr bool is_pure() const { - return (bitfield_ | kPureMask) == kPureValue; + return (bitfield_ & kPureMask) == kPureValue; } constexpr bool is_required_when_unused() const { return can_write() || non_memory_side_effects(); diff --git a/deps/v8/src/wasm/wasm-code-manager.h b/deps/v8/src/wasm/wasm-code-manager.h index 137c3074d503f0..c6e878a1db508e 100644 --- a/deps/v8/src/wasm/wasm-code-manager.h +++ b/deps/v8/src/wasm/wasm-code-manager.h @@ -474,7 +474,7 @@ class V8_EXPORT_PRIVATE WasmCode final { int trap_handler_index_ = -1; // Bits encoded in {flags_}: - using KindField = base::BitField8; + using KindField = base::BitField8; using ExecutionTierField = KindField::Next; using ForDebuggingField = ExecutionTierField::Next;