Skip to content

Commit 678641f

Browse files
Bo98richardlau
authored andcommittedApr 17, 2024
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 <thakis@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Hannes Payer <hpayer@chromium.org> Auto-Submit: Nico Weber <thakis@chromium.org> Cr-Commit-Position: refs/heads/main@{#82109} Refs: v8/v8@d15d49b PR-URL: #52337 Fixes: #52230 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent c60cd67 commit 678641f

File tree

7 files changed

+13
-8
lines changed

7 files changed

+13
-8
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.36',
39+
'v8_embedder_string': '-node.37',
4040

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

‎deps/v8/src/ast/ast.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ class Literal final : public Expression {
999999
friend class AstNodeFactory;
10001000
friend Zone;
10011001

1002-
using TypeField = Expression::NextBitField<Type, 4>;
1002+
using TypeField = Expression::NextBitField<Type, 3>;
10031003

10041004
Literal(int smi, int position) : Expression(position, kLiteral), smi_(smi) {
10051005
bit_field_ = TypeField::update(bit_field_, kSmi);

‎deps/v8/src/base/bit-field.h

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ class BitField final {
4040
static constexpr U kNumValues = U{1} << kSize;
4141

4242
// Value for the field with all bits set.
43+
// If clang complains
44+
// "constexpr variable 'kMax' must be initialized by a constant expression"
45+
// on this line, then you're creating a BitField for an enum with more bits
46+
// than needed for the enum values. Either reduce the BitField size,
47+
// or give the enum an explicit underlying type.
4348
static constexpr T kMax = static_cast<T>(kNumValues - 1);
4449

4550
template <class T2, int size2>

‎deps/v8/src/compiler/backend/instruction-codes.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
195195
V(None) \
196196
TARGET_ADDRESSING_MODE_LIST(V)
197197

198-
enum AddressingMode {
198+
enum AddressingMode : uint8_t {
199199
#define DECLARE_ADDRESSING_MODE(Name) kMode_##Name,
200200
ADDRESSING_MODE_LIST(DECLARE_ADDRESSING_MODE)
201201
#undef DECLARE_ADDRESSING_MODE
@@ -306,7 +306,7 @@ using MiscField = base::BitField<int, 22, 10>;
306306
// LaneSizeField and AccessModeField are helper types to encode/decode a lane
307307
// size, an access mode, or both inside the overlapping MiscField.
308308
using LaneSizeField = base::BitField<int, 22, 8>;
309-
using AccessModeField = base::BitField<MemoryAccessMode, 30, 2>;
309+
using AccessModeField = base::BitField<MemoryAccessMode, 30, 1>;
310310
// TODO(turbofan): {HasMemoryAccessMode} is currently only used to guard
311311
// decoding (in CodeGenerator and InstructionScheduler). Encoding (in
312312
// InstructionSelector) is not yet guarded. There are in fact instructions for

‎deps/v8/src/compiler/backend/instruction.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,8 @@ class LocationOperand : public InstructionOperand {
586586
}
587587

588588
STATIC_ASSERT(KindField::kSize == 3);
589-
using LocationKindField = base::BitField64<LocationKind, 3, 2>;
590-
using RepresentationField = base::BitField64<MachineRepresentation, 5, 8>;
589+
using LocationKindField = base::BitField64<LocationKind, 3, 1>;
590+
using RepresentationField = LocationKindField::Next<MachineRepresentation, 8>;
591591
using IndexField = base::BitField64<int32_t, 35, 29>;
592592
};
593593

‎deps/v8/src/maglev/maglev-ir.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class OpProperties {
196196
}
197197

198198
constexpr bool is_pure() const {
199-
return (bitfield_ | kPureMask) == kPureValue;
199+
return (bitfield_ & kPureMask) == kPureValue;
200200
}
201201
constexpr bool is_required_when_unused() const {
202202
return can_write() || non_memory_side_effects();

‎deps/v8/src/wasm/wasm-code-manager.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ class V8_EXPORT_PRIVATE WasmCode final {
474474
int trap_handler_index_ = -1;
475475

476476
// Bits encoded in {flags_}:
477-
using KindField = base::BitField8<Kind, 0, 3>;
477+
using KindField = base::BitField8<Kind, 0, 2>;
478478
using ExecutionTierField = KindField::Next<ExecutionTier, 2>;
479479
using ForDebuggingField = ExecutionTierField::Next<ForDebugging, 2>;
480480

0 commit comments

Comments
 (0)
Please sign in to comment.