Commit 0cabc6a0 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

Reland "[utils] Make BitField final"

This is a reland of 658ff200

Original change's description:
> [utils] Make BitField final
> 
> We have hundreds of classes that derive from {BitField} without adding
> any functionality. This CL switches all such occurrences to 'using'
> declarations instead.
> 
> Before:
>   class MyBitField : public BitField<int, 6, 4, MyEnum> {};
> After:
>   using MyBitField = BitField<int, 6, 4, MyEnum>;
> 
> This might reduce compilation time by reducing the number of existing
> classes.
> 
> The old pattern is forbidden now by making {BitField} final.
> 
> R=yangguo@chromium.org
> 
> Bug: v8:9396, v8:7629
> Change-Id: I8a8364707e8eae0bb522af2459c160e3293eecbb
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1722565
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#62956}

Bug: v8:9396, v8:7629
Change-Id: Ic68541af9d1e8d0340691970922f282b24a9767f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1724379Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62959}
parent 753a07db
This diff is collapsed.
...@@ -243,25 +243,21 @@ class Variable final : public ZoneObject { ...@@ -243,25 +243,21 @@ class Variable final : public ZoneObject {
bit_field_ = MaybeAssignedFlagField::update(bit_field_, kMaybeAssigned); bit_field_ = MaybeAssignedFlagField::update(bit_field_, kMaybeAssigned);
} }
class VariableModeField : public BitField16<VariableMode, 0, 3> {}; using VariableModeField = BitField16<VariableMode, 0, 3>;
class VariableKindField using VariableKindField =
: public BitField16<VariableKind, VariableModeField::kNext, 3> {}; BitField16<VariableKind, VariableModeField::kNext, 3>;
class LocationField using LocationField =
: public BitField16<VariableLocation, VariableKindField::kNext, 3> {}; BitField16<VariableLocation, VariableKindField::kNext, 3>;
class ForceContextAllocationField using ForceContextAllocationField = BitField16<bool, LocationField::kNext, 1>;
: public BitField16<bool, LocationField::kNext, 1> {}; using IsUsedField = BitField16<bool, ForceContextAllocationField::kNext, 1>;
class IsUsedField using InitializationFlagField =
: public BitField16<bool, ForceContextAllocationField::kNext, 1> {}; BitField16<InitializationFlag, IsUsedField::kNext, 1>;
class InitializationFlagField using ForceHoleInitializationField =
: public BitField16<InitializationFlag, IsUsedField::kNext, 1> {}; BitField16<bool, InitializationFlagField::kNext, 1>;
class ForceHoleInitializationField using MaybeAssignedFlagField =
: public BitField16<bool, InitializationFlagField::kNext, 1> {}; BitField16<MaybeAssignedFlag, ForceHoleInitializationField::kNext, 1>;
class MaybeAssignedFlagField using RequiresBrandCheckField =
: public BitField16<MaybeAssignedFlag, BitField16<RequiresBrandCheckFlag, MaybeAssignedFlagField::kNext, 1>;
ForceHoleInitializationField::kNext, 1> {};
class RequiresBrandCheckField
: public BitField16<RequiresBrandCheckFlag, MaybeAssignedFlagField::kNext,
1> {};
Variable** next() { return &next_; } Variable** next() { return &next_; }
friend List; friend List;
friend base::ThreadedListTraits<Variable>; friend base::ThreadedListTraits<Variable>;
......
...@@ -782,10 +782,10 @@ class ArrayConcatVisitor { ...@@ -782,10 +782,10 @@ class ArrayConcatVisitor {
storage_ = isolate_->global_handles()->Create(storage); storage_ = isolate_->global_handles()->Create(storage);
} }
class FastElementsField : public BitField<bool, 0, 1> {}; using FastElementsField = BitField<bool, 0, 1>;
class ExceedsLimitField : public BitField<bool, 1, 1> {}; using ExceedsLimitField = BitField<bool, 1, 1>;
class IsFixedArrayField : public BitField<bool, 2, 1> {}; using IsFixedArrayField = BitField<bool, 2, 1>;
class HasSimpleElementsField : public BitField<bool, 3, 1> {}; using HasSimpleElementsField = BitField<bool, 3, 1>;
bool fast_elements() const { return FastElementsField::decode(bit_field_); } bool fast_elements() const { return FastElementsField::decode(bit_field_); }
void set_fast_elements(bool fast) { void set_fast_elements(bool fast) {
......
...@@ -129,8 +129,8 @@ class V8_EXPORT_PRIVATE HandlerTable { ...@@ -129,8 +129,8 @@ class V8_EXPORT_PRIVATE HandlerTable {
static const int kReturnEntrySize = 2; static const int kReturnEntrySize = 2;
// Encoding of the {handler} field. // Encoding of the {handler} field.
class HandlerPredictionField : public BitField<CatchPrediction, 0, 3> {}; using HandlerPredictionField = BitField<CatchPrediction, 0, 3>;
class HandlerOffsetField : public BitField<int, 3, 29> {}; using HandlerOffsetField = BitField<int, 3, 29>;
}; };
} // namespace internal } // namespace internal
......
...@@ -342,8 +342,8 @@ class Displacement { ...@@ -342,8 +342,8 @@ class Displacement {
private: private:
int data_; int data_;
class TypeField : public BitField<Type, 0, 2> {}; using TypeField = BitField<Type, 0, 2>;
class NextField : public BitField<int, 2, 32 - 2> {}; using NextField = BitField<int, 2, 32 - 2>;
void init(Label* L, Type type); void init(Label* L, Type type);
}; };
......
...@@ -27,8 +27,8 @@ namespace internal { ...@@ -27,8 +27,8 @@ namespace internal {
namespace { namespace {
// Each byte is encoded as MoreBit | ValueBits. // Each byte is encoded as MoreBit | ValueBits.
class MoreBit : public BitField8<bool, 7, 1> {}; using MoreBit = BitField8<bool, 7, 1>;
class ValueBits : public BitField8<unsigned, 0, 7> {}; using ValueBits = BitField8<unsigned, 0, 7>;
// Helper: Add the offsets from 'other' to 'value'. Also set is_statement. // Helper: Add the offsets from 'other' to 'value'. Also set is_statement.
void AddAndSetEntry(PositionTableEntry& value, // NOLINT(runtime/references) void AddAndSetEntry(PositionTableEntry& value, // NOLINT(runtime/references)
......
...@@ -92,16 +92,18 @@ bool PerThreadAssertScope<kType, kAllow>::IsAllowed() { ...@@ -92,16 +92,18 @@ bool PerThreadAssertScope<kType, kAllow>::IsAllowed() {
return current_data == nullptr || current_data->Get(kType); return current_data == nullptr || current_data->Get(kType);
} }
template <PerIsolateAssertType kType, bool kAllow> namespace {
class PerIsolateAssertScope<kType, kAllow>::DataBit template <PerIsolateAssertType kType>
: public BitField<bool, kType, 1> {}; using DataBit = BitField<bool, kType, 1>;
}
template <PerIsolateAssertType kType, bool kAllow> template <PerIsolateAssertType kType, bool kAllow>
PerIsolateAssertScope<kType, kAllow>::PerIsolateAssertScope(Isolate* isolate) PerIsolateAssertScope<kType, kAllow>::PerIsolateAssertScope(Isolate* isolate)
: isolate_(isolate), old_data_(isolate->per_isolate_assert_data()) { : isolate_(isolate), old_data_(isolate->per_isolate_assert_data()) {
DCHECK_NOT_NULL(isolate); DCHECK_NOT_NULL(isolate);
STATIC_ASSERT(kType < 32); STATIC_ASSERT(kType < 32);
isolate_->set_per_isolate_assert_data(DataBit::update(old_data_, kAllow)); isolate_->set_per_isolate_assert_data(
DataBit<kType>::update(old_data_, kAllow));
} }
template <PerIsolateAssertType kType, bool kAllow> template <PerIsolateAssertType kType, bool kAllow>
...@@ -112,7 +114,7 @@ PerIsolateAssertScope<kType, kAllow>::~PerIsolateAssertScope() { ...@@ -112,7 +114,7 @@ PerIsolateAssertScope<kType, kAllow>::~PerIsolateAssertScope() {
// static // static
template <PerIsolateAssertType kType, bool kAllow> template <PerIsolateAssertType kType, bool kAllow>
bool PerIsolateAssertScope<kType, kAllow>::IsAllowed(Isolate* isolate) { bool PerIsolateAssertScope<kType, kAllow>::IsAllowed(Isolate* isolate) {
return DataBit::decode(isolate->per_isolate_assert_data()); return DataBit<kType>::decode(isolate->per_isolate_assert_data());
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -81,8 +81,6 @@ class PerIsolateAssertScope { ...@@ -81,8 +81,6 @@ class PerIsolateAssertScope {
static bool IsAllowed(Isolate* isolate); static bool IsAllowed(Isolate* isolate);
private: private:
class DataBit;
Isolate* isolate_; Isolate* isolate_;
uint32_t old_data_; uint32_t old_data_;
......
...@@ -130,7 +130,7 @@ class V8_EXPORT_PRIVATE InstructionOperand { ...@@ -130,7 +130,7 @@ class V8_EXPORT_PRIVATE InstructionOperand {
inline uint64_t GetCanonicalizedValue() const; inline uint64_t GetCanonicalizedValue() const;
class KindField : public BitField64<Kind, 0, 3> {}; using KindField = BitField64<Kind, 0, 3>;
uint64_t value_; uint64_t value_;
}; };
...@@ -331,20 +331,20 @@ class UnallocatedOperand final : public InstructionOperand { ...@@ -331,20 +331,20 @@ class UnallocatedOperand final : public InstructionOperand {
STATIC_ASSERT(KindField::kSize == 3); STATIC_ASSERT(KindField::kSize == 3);
class VirtualRegisterField : public BitField64<uint32_t, 3, 32> {}; using VirtualRegisterField = BitField64<uint32_t, 3, 32>;
// BitFields for all unallocated operands. // BitFields for all unallocated operands.
class BasicPolicyField : public BitField64<BasicPolicy, 35, 1> {}; using BasicPolicyField = BitField64<BasicPolicy, 35, 1>;
// BitFields specific to BasicPolicy::FIXED_SLOT. // BitFields specific to BasicPolicy::FIXED_SLOT.
class FixedSlotIndexField : public BitField64<int, 36, 28> {}; using FixedSlotIndexField = BitField64<int, 36, 28>;
// BitFields specific to BasicPolicy::EXTENDED_POLICY. // BitFields specific to BasicPolicy::EXTENDED_POLICY.
class ExtendedPolicyField : public BitField64<ExtendedPolicy, 36, 3> {}; using ExtendedPolicyField = BitField64<ExtendedPolicy, 36, 3>;
class LifetimeField : public BitField64<Lifetime, 39, 1> {}; using LifetimeField = BitField64<Lifetime, 39, 1>;
class HasSecondaryStorageField : public BitField64<bool, 40, 1> {}; using HasSecondaryStorageField = BitField64<bool, 40, 1>;
class FixedRegisterField : public BitField64<int, 41, 6> {}; using FixedRegisterField = BitField64<int, 41, 6>;
class SecondaryStorageField : public BitField64<int, 47, 3> {}; using SecondaryStorageField = BitField64<int, 47, 3>;
private: private:
explicit UnallocatedOperand(int virtual_register) explicit UnallocatedOperand(int virtual_register)
...@@ -373,7 +373,7 @@ class ConstantOperand : public InstructionOperand { ...@@ -373,7 +373,7 @@ class ConstantOperand : public InstructionOperand {
INSTRUCTION_OPERAND_CASTS(ConstantOperand, CONSTANT) INSTRUCTION_OPERAND_CASTS(ConstantOperand, CONSTANT)
STATIC_ASSERT(KindField::kSize == 3); STATIC_ASSERT(KindField::kSize == 3);
class VirtualRegisterField : public BitField64<uint32_t, 3, 32> {}; using VirtualRegisterField = BitField64<uint32_t, 3, 32>;
}; };
class ImmediateOperand : public InstructionOperand { class ImmediateOperand : public InstructionOperand {
...@@ -406,8 +406,8 @@ class ImmediateOperand : public InstructionOperand { ...@@ -406,8 +406,8 @@ class ImmediateOperand : public InstructionOperand {
INSTRUCTION_OPERAND_CASTS(ImmediateOperand, IMMEDIATE) INSTRUCTION_OPERAND_CASTS(ImmediateOperand, IMMEDIATE)
STATIC_ASSERT(KindField::kSize == 3); STATIC_ASSERT(KindField::kSize == 3);
class TypeField : public BitField64<ImmediateType, 3, 1> {}; using TypeField = BitField64<ImmediateType, 3, 1>;
class ValueField : public BitField64<int32_t, 32, 32> {}; using ValueField = BitField64<int32_t, 32, 32>;
}; };
class LocationOperand : public InstructionOperand { class LocationOperand : public InstructionOperand {
...@@ -509,9 +509,9 @@ class LocationOperand : public InstructionOperand { ...@@ -509,9 +509,9 @@ class LocationOperand : public InstructionOperand {
} }
STATIC_ASSERT(KindField::kSize == 3); STATIC_ASSERT(KindField::kSize == 3);
class LocationKindField : public BitField64<LocationKind, 3, 2> {}; using LocationKindField = BitField64<LocationKind, 3, 2>;
class RepresentationField : public BitField64<MachineRepresentation, 5, 8> {}; using RepresentationField = BitField64<MachineRepresentation, 5, 8>;
class IndexField : public BitField64<int32_t, 35, 29> {}; using IndexField = BitField64<int32_t, 35, 29>;
}; };
class V8_EXPORT_PRIVATE ExplicitOperand class V8_EXPORT_PRIVATE ExplicitOperand
......
...@@ -144,8 +144,8 @@ class LinkageLocation { ...@@ -144,8 +144,8 @@ class LinkageLocation {
private: private:
enum LocationType { REGISTER, STACK_SLOT }; enum LocationType { REGISTER, STACK_SLOT };
class TypeField : public BitField<LocationType, 0, 1> {}; using TypeField = BitField<LocationType, 0, 1>;
class LocationField : public BitField<int32_t, TypeField::kNext, 31> {}; using LocationField = BitField<int32_t, TypeField::kNext, 31>;
static constexpr int32_t ANY_REGISTER = -1; static constexpr int32_t ANY_REGISTER = -1;
static constexpr int32_t MAX_STACK_SLOT = 32767; static constexpr int32_t MAX_STACK_SLOT = 32767;
......
...@@ -580,10 +580,9 @@ class GlobalHandles::Node final : public NodeBase<GlobalHandles::Node> { ...@@ -580,10 +580,9 @@ class GlobalHandles::Node final : public NodeBase<GlobalHandles::Node> {
// This stores three flags (independent, partially_dependent and // This stores three flags (independent, partially_dependent and
// in_young_list) and a State. // in_young_list) and a State.
class NodeState : public BitField8<State, 0, 3> {}; using NodeState = BitField8<State, 0, 3>;
class IsInYoungList : public BitField8<bool, NodeState::kNext, 1> {}; using IsInYoungList = BitField8<bool, NodeState::kNext, 1>;
class NodeWeaknessType using NodeWeaknessType = BitField8<WeaknessType, IsInYoungList::kNext, 2>;
: public BitField8<WeaknessType, IsInYoungList::kNext, 2> {};
// Handle specific callback - might be a weak reference in disguise. // Handle specific callback - might be a weak reference in disguise.
WeakCallbackInfo<void>::Callback weak_callback_; WeakCallbackInfo<void>::Callback weak_callback_;
...@@ -650,9 +649,9 @@ class GlobalHandles::TracedNode final ...@@ -650,9 +649,9 @@ class GlobalHandles::TracedNode final
} }
protected: protected:
class NodeState : public BitField8<State, 0, 2> {}; using NodeState = BitField8<State, 0, 2>;
class IsInYoungList : public BitField8<bool, NodeState::kNext, 1> {}; using IsInYoungList = BitField8<bool, NodeState::kNext, 1>;
class IsRoot : public BitField8<bool, IsInYoungList::kNext, 1> {}; using IsRoot = BitField8<bool, IsInYoungList::kNext, 1>;
void ClearImplFields() { void ClearImplFields() {
set_root(true); set_root(true);
......
...@@ -411,8 +411,8 @@ class V8_EXPORT_PRIVATE TypedSlots { ...@@ -411,8 +411,8 @@ class V8_EXPORT_PRIVATE TypedSlots {
void Merge(TypedSlots* other); void Merge(TypedSlots* other);
protected: protected:
class OffsetField : public BitField<int, 0, 29> {}; using OffsetField = BitField<int, 0, 29>;
class TypeField : public BitField<SlotType, 29, 3> {}; using TypeField = BitField<SlotType, 29, 3>;
struct TypedSlot { struct TypedSlot {
uint32_t type_and_offset; uint32_t type_and_offset;
}; };
......
...@@ -47,65 +47,60 @@ class LoadHandler final : public DataHandler { ...@@ -47,65 +47,60 @@ class LoadHandler final : public DataHandler {
kNonExistent, kNonExistent,
kModuleExport kModuleExport
}; };
class KindBits : public BitField<Kind, 0, 4> {}; using KindBits = BitField<Kind, 0, 4>;
// Defines whether access rights check should be done on receiver object. // Defines whether access rights check should be done on receiver object.
// Applicable to named property kinds only when loading value from prototype // Applicable to named property kinds only when loading value from prototype
// chain. Ignored when loading from holder. // chain. Ignored when loading from holder.
class DoAccessCheckOnReceiverBits using DoAccessCheckOnReceiverBits = BitField<bool, KindBits::kNext, 1>;
: public BitField<bool, KindBits::kNext, 1> {};
// Defines whether a lookup should be done on receiver object before // Defines whether a lookup should be done on receiver object before
// proceeding to the prototype chain. Applicable to named property kinds only // proceeding to the prototype chain. Applicable to named property kinds only
// when loading value from prototype chain. Ignored when loading from holder. // when loading value from prototype chain. Ignored when loading from holder.
class LookupOnReceiverBits using LookupOnReceiverBits =
: public BitField<bool, DoAccessCheckOnReceiverBits::kNext, 1> {}; BitField<bool, DoAccessCheckOnReceiverBits::kNext, 1>;
// //
// Encoding when KindBits contains kForConstants. // Encoding when KindBits contains kForConstants.
// //
// Index of a value entry in the descriptor array. // Index of a value entry in the descriptor array.
class DescriptorBits : public BitField<unsigned, LookupOnReceiverBits::kNext, using DescriptorBits =
kDescriptorIndexBitCount> {}; BitField<unsigned, LookupOnReceiverBits::kNext, kDescriptorIndexBitCount>;
// Make sure we don't overflow the smi. // Make sure we don't overflow the smi.
STATIC_ASSERT(DescriptorBits::kNext <= kSmiValueSize); STATIC_ASSERT(DescriptorBits::kNext <= kSmiValueSize);
// //
// Encoding when KindBits contains kField. // Encoding when KindBits contains kField.
// //
class IsInobjectBits : public BitField<bool, LookupOnReceiverBits::kNext, 1> { using IsInobjectBits = BitField<bool, LookupOnReceiverBits::kNext, 1>;
}; using IsDoubleBits = BitField<bool, IsInobjectBits::kNext, 1>;
class IsDoubleBits : public BitField<bool, IsInobjectBits::kNext, 1> {};
// +1 here is to cover all possible JSObject header sizes. // +1 here is to cover all possible JSObject header sizes.
class FieldIndexBits : public BitField<unsigned, IsDoubleBits::kNext, using FieldIndexBits =
kDescriptorIndexBitCount + 1> {}; BitField<unsigned, IsDoubleBits::kNext, kDescriptorIndexBitCount + 1>;
// Make sure we don't overflow the smi. // Make sure we don't overflow the smi.
STATIC_ASSERT(FieldIndexBits::kNext <= kSmiValueSize); STATIC_ASSERT(FieldIndexBits::kNext <= kSmiValueSize);
// //
// Encoding when KindBits contains kElement or kIndexedString. // Encoding when KindBits contains kElement or kIndexedString.
// //
class AllowOutOfBoundsBits using AllowOutOfBoundsBits = BitField<bool, LookupOnReceiverBits::kNext, 1>;
: public BitField<bool, LookupOnReceiverBits::kNext, 1> {};
// //
// Encoding when KindBits contains kElement. // Encoding when KindBits contains kElement.
// //
class IsJsArrayBits : public BitField<bool, AllowOutOfBoundsBits::kNext, 1> { using IsJsArrayBits = BitField<bool, AllowOutOfBoundsBits::kNext, 1>;
}; using ConvertHoleBits = BitField<bool, IsJsArrayBits::kNext, 1>;
class ConvertHoleBits : public BitField<bool, IsJsArrayBits::kNext, 1> {}; using ElementsKindBits = BitField<ElementsKind, ConvertHoleBits::kNext, 8>;
class ElementsKindBits
: public BitField<ElementsKind, ConvertHoleBits::kNext, 8> {};
// Make sure we don't overflow the smi. // Make sure we don't overflow the smi.
STATIC_ASSERT(ElementsKindBits::kNext <= kSmiValueSize); STATIC_ASSERT(ElementsKindBits::kNext <= kSmiValueSize);
// //
// Encoding when KindBits contains kModuleExport. // Encoding when KindBits contains kModuleExport.
// //
class ExportsIndexBits using ExportsIndexBits =
: public BitField<unsigned, LookupOnReceiverBits::kNext, BitField<unsigned, LookupOnReceiverBits::kNext,
kSmiValueSize - LookupOnReceiverBits::kNext> {}; kSmiValueSize - LookupOnReceiverBits::kNext>;
// Decodes kind from Smi-handler. // Decodes kind from Smi-handler.
static inline Kind GetHandlerKind(Smi smi_handler); static inline Kind GetHandlerKind(Smi smi_handler);
...@@ -206,28 +201,27 @@ class StoreHandler final : public DataHandler { ...@@ -206,28 +201,27 @@ class StoreHandler final : public DataHandler {
kProxy, kProxy,
kKindsNumber // Keep last kKindsNumber // Keep last
}; };
class KindBits : public BitField<Kind, 0, 4> {}; using KindBits = BitField<Kind, 0, 4>;
enum FieldRepresentation { kSmi, kDouble, kHeapObject, kTagged }; enum FieldRepresentation { kSmi, kDouble, kHeapObject, kTagged };
// Applicable to kGlobalProxy, kProxy kinds. // Applicable to kGlobalProxy, kProxy kinds.
// Defines whether access rights check should be done on receiver object. // Defines whether access rights check should be done on receiver object.
class DoAccessCheckOnReceiverBits using DoAccessCheckOnReceiverBits = BitField<bool, KindBits::kNext, 1>;
: public BitField<bool, KindBits::kNext, 1> {};
// Defines whether a lookup should be done on receiver object before // Defines whether a lookup should be done on receiver object before
// proceeding to the prototype chain. Applicable to named property kinds only // proceeding to the prototype chain. Applicable to named property kinds only
// when storing through prototype chain. Ignored when storing to holder. // when storing through prototype chain. Ignored when storing to holder.
class LookupOnReceiverBits using LookupOnReceiverBits =
: public BitField<bool, DoAccessCheckOnReceiverBits::kNext, 1> {}; BitField<bool, DoAccessCheckOnReceiverBits::kNext, 1>;
// Applicable to kField, kTransitionToField and kTransitionToConstant // Applicable to kField, kTransitionToField and kTransitionToConstant
// kinds. // kinds.
// Index of a value entry in the descriptor array. // Index of a value entry in the descriptor array.
class DescriptorBits : public BitField<unsigned, LookupOnReceiverBits::kNext, using DescriptorBits =
kDescriptorIndexBitCount> {}; BitField<unsigned, LookupOnReceiverBits::kNext, kDescriptorIndexBitCount>;
// //
// Encoding when KindBits contains kTransitionToConstant. // Encoding when KindBits contains kTransitionToConstant.
// //
...@@ -238,13 +232,12 @@ class StoreHandler final : public DataHandler { ...@@ -238,13 +232,12 @@ class StoreHandler final : public DataHandler {
// //
// Encoding when KindBits contains kField or kTransitionToField. // Encoding when KindBits contains kField or kTransitionToField.
// //
class IsInobjectBits : public BitField<bool, DescriptorBits::kNext, 1> {}; using IsInobjectBits = BitField<bool, DescriptorBits::kNext, 1>;
class FieldRepresentationBits using FieldRepresentationBits =
: public BitField<FieldRepresentation, IsInobjectBits::kNext, 2> {}; BitField<FieldRepresentation, IsInobjectBits::kNext, 2>;
// +1 here is to cover all possible JSObject header sizes. // +1 here is to cover all possible JSObject header sizes.
class FieldIndexBits using FieldIndexBits = BitField<unsigned, FieldRepresentationBits::kNext,
: public BitField<unsigned, FieldRepresentationBits::kNext, kDescriptorIndexBitCount + 1>;
kDescriptorIndexBitCount + 1> {};
// Make sure we don't overflow the smi. // Make sure we don't overflow the smi.
STATIC_ASSERT(FieldIndexBits::kNext <= kSmiValueSize); STATIC_ASSERT(FieldIndexBits::kNext <= kSmiValueSize);
......
...@@ -18,8 +18,8 @@ namespace interpreter { ...@@ -18,8 +18,8 @@ namespace interpreter {
class CreateArrayLiteralFlags { class CreateArrayLiteralFlags {
public: public:
class FlagsBits : public BitField8<int, 0, 5> {}; using FlagsBits = BitField8<int, 0, 5>;
class FastCloneSupportedBit : public BitField8<bool, FlagsBits::kNext, 1> {}; using FastCloneSupportedBit = BitField8<bool, FlagsBits::kNext, 1>;
static uint8_t Encode(bool use_fast_shallow_clone, int runtime_flags); static uint8_t Encode(bool use_fast_shallow_clone, int runtime_flags);
...@@ -29,8 +29,8 @@ class CreateArrayLiteralFlags { ...@@ -29,8 +29,8 @@ class CreateArrayLiteralFlags {
class CreateObjectLiteralFlags { class CreateObjectLiteralFlags {
public: public:
class FlagsBits : public BitField8<int, 0, 5> {}; using FlagsBits = BitField8<int, 0, 5>;
class FastCloneSupportedBit : public BitField8<bool, FlagsBits::kNext, 1> {}; using FastCloneSupportedBit = BitField8<bool, FlagsBits::kNext, 1>;
static uint8_t Encode(int runtime_flags, bool fast_clone_supported); static uint8_t Encode(int runtime_flags, bool fast_clone_supported);
...@@ -40,8 +40,8 @@ class CreateObjectLiteralFlags { ...@@ -40,8 +40,8 @@ class CreateObjectLiteralFlags {
class CreateClosureFlags { class CreateClosureFlags {
public: public:
class PretenuredBit : public BitField8<bool, 0, 1> {}; using PretenuredBit = BitField8<bool, 0, 1>;
class FastNewClosureBit : public BitField8<bool, PretenuredBit::kNext, 1> {}; using FastNewClosureBit = BitField8<bool, PretenuredBit::kNext, 1>;
static uint8_t Encode(bool pretenure, bool is_function_scope, static uint8_t Encode(bool pretenure, bool is_function_scope,
bool might_always_opt); bool might_always_opt);
...@@ -80,9 +80,8 @@ class TestTypeOfFlags { ...@@ -80,9 +80,8 @@ class TestTypeOfFlags {
class StoreLookupSlotFlags { class StoreLookupSlotFlags {
public: public:
class LanguageModeBit : public BitField8<LanguageMode, 0, 1> {}; using LanguageModeBit = BitField8<LanguageMode, 0, 1>;
class LookupHoistingModeBit using LookupHoistingModeBit = BitField8<bool, LanguageModeBit::kNext, 1>;
: public BitField8<bool, LanguageModeBit::kNext, 1> {};
STATIC_ASSERT(LanguageModeSize <= LanguageModeBit::kNumValues); STATIC_ASSERT(LanguageModeSize <= LanguageModeBit::kNumValues);
static uint8_t Encode(LanguageMode language_mode, static uint8_t Encode(LanguageMode language_mode,
......
...@@ -66,14 +66,14 @@ class AllocationSite : public Struct { ...@@ -66,14 +66,14 @@ class AllocationSite : public Struct {
bool IsNested(); bool IsNested();
// transition_info bitfields, for constructed array transition info. // transition_info bitfields, for constructed array transition info.
class ElementsKindBits : public BitField<ElementsKind, 0, 5> {}; using ElementsKindBits = BitField<ElementsKind, 0, 5>;
class DoNotInlineBit : public BitField<bool, 5, 1> {}; using DoNotInlineBit = BitField<bool, 5, 1>;
// Unused bits 6-30. // Unused bits 6-30.
// Bitfields for pretenure_data // Bitfields for pretenure_data
class MementoFoundCountBits : public BitField<int, 0, 26> {}; using MementoFoundCountBits = BitField<int, 0, 26>;
class PretenureDecisionBits : public BitField<PretenureDecision, 26, 3> {}; using PretenureDecisionBits = BitField<PretenureDecision, 26, 3>;
class DeoptDependentCodeBit : public BitField<bool, 29, 1> {}; using DeoptDependentCodeBit = BitField<bool, 29, 1>;
STATIC_ASSERT(PretenureDecisionBits::kMax >= kLastPretenureDecisionValue); STATIC_ASSERT(PretenureDecisionBits::kMax >= kLastPretenureDecisionValue);
// Increments the mementos found counter and returns true when the first // Increments the mementos found counter and returns true when the first
......
...@@ -57,8 +57,8 @@ class BigIntBase : public HeapObject { ...@@ -57,8 +57,8 @@ class BigIntBase : public HeapObject {
// able to read the length concurrently, the getters and setters are atomic. // able to read the length concurrently, the getters and setters are atomic.
static const int kLengthFieldBits = 30; static const int kLengthFieldBits = 30;
STATIC_ASSERT(kMaxLength <= ((1 << kLengthFieldBits) - 1)); STATIC_ASSERT(kMaxLength <= ((1 << kLengthFieldBits) - 1));
class SignBits : public BitField<bool, 0, 1> {}; using SignBits = BitField<bool, 0, 1>;
class LengthBits : public BitField<int, SignBits::kNext, kLengthFieldBits> {}; using LengthBits = BitField<int, SignBits::kNext, kLengthFieldBits>;
STATIC_ASSERT(LengthBits::kNext <= 32); STATIC_ASSERT(LengthBits::kNext <= 32);
// Layout description. // Layout description.
......
...@@ -706,8 +706,8 @@ class DependentCode : public WeakFixedArray { ...@@ -706,8 +706,8 @@ class DependentCode : public WeakFixedArray {
inline int flags(); inline int flags();
inline void set_flags(int flags); inline void set_flags(int flags);
class GroupField : public BitField<int, 0, 3> {}; using GroupField = BitField<int, 0, 3>;
class CountField : public BitField<int, 3, 27> {}; using CountField = BitField<int, 3, 27>;
STATIC_ASSERT(kGroupCount <= GroupField::kMax + 1); STATIC_ASSERT(kGroupCount <= GroupField::kMax + 1);
OBJECT_CONSTRUCTORS(DependentCode, WeakFixedArray); OBJECT_CONSTRUCTORS(DependentCode, WeakFixedArray);
......
...@@ -107,17 +107,16 @@ class FieldIndex final { ...@@ -107,17 +107,16 @@ class FieldIndex final {
(kDescriptorIndexBitCount + 1 + kTaggedSizeLog2); (kDescriptorIndexBitCount + 1 + kTaggedSizeLog2);
// Index from beginning of object. // Index from beginning of object.
class OffsetBits : public BitField64<int, 0, kOffsetBitsSize> {}; using OffsetBits = BitField64<int, 0, kOffsetBitsSize>;
class IsInObjectBits : public BitField64<bool, OffsetBits::kNext, 1> {}; using IsInObjectBits = BitField64<bool, OffsetBits::kNext, 1>;
class EncodingBits : public BitField64<Encoding, IsInObjectBits::kNext, 2> {}; using EncodingBits = BitField64<Encoding, IsInObjectBits::kNext, 2>;
// Number of inobject properties. // Number of inobject properties.
class InObjectPropertyBits using InObjectPropertyBits =
: public BitField64<int, EncodingBits::kNext, kDescriptorIndexBitCount> { BitField64<int, EncodingBits::kNext, kDescriptorIndexBitCount>;
};
// Offset of first inobject property from beginning of object. // Offset of first inobject property from beginning of object.
class FirstInobjectPropertyOffsetBits using FirstInobjectPropertyOffsetBits =
: public BitField64<int, InObjectPropertyBits::kNext, BitField64<int, InObjectPropertyBits::kNext,
kFirstInobjectPropertyOffsetBitCount> {}; kFirstInobjectPropertyOffsetBitCount>;
STATIC_ASSERT(FirstInobjectPropertyOffsetBits::kNext <= 64); STATIC_ASSERT(FirstInobjectPropertyOffsetBits::kNext <= 64);
uint64_t bit_field_; uint64_t bit_field_;
......
...@@ -79,7 +79,7 @@ class JSPromise : public JSObject { ...@@ -79,7 +79,7 @@ class JSPromise : public JSObject {
static const int kStatusBits = 2; static const int kStatusBits = 2;
static const int kHasHandlerBit = 2; static const int kHasHandlerBit = 2;
static const int kHandledHintBit = 3; static const int kHandledHintBit = 3;
class AsyncTaskIdField : public BitField<int, kHandledHintBit + 1, 22> {}; using AsyncTaskIdField = BitField<int, kHandledHintBit + 1, 22>;
static const int kStatusShift = 0; static const int kStatusShift = 0;
static const int kStatusMask = 0x3; static const int kStatusMask = 0x3;
......
...@@ -67,7 +67,7 @@ class JSFinalizationGroup : public JSObject { ...@@ -67,7 +67,7 @@ class JSFinalizationGroup : public JSObject {
TORQUE_GENERATED_JSFINALIZATION_GROUP_FIELDS) TORQUE_GENERATED_JSFINALIZATION_GROUP_FIELDS)
// Bitfields in flags. // Bitfields in flags.
class ScheduledForCleanupField : public BitField<bool, 0, 1> {}; using ScheduledForCleanupField = BitField<bool, 0, 1>;
OBJECT_CONSTRUCTORS(JSFinalizationGroup, JSObject); OBJECT_CONSTRUCTORS(JSFinalizationGroup, JSObject);
}; };
......
...@@ -99,12 +99,11 @@ class Name : public TorqueGeneratedName<Name, HeapObject> { ...@@ -99,12 +99,11 @@ class Name : public TorqueGeneratedName<Name, HeapObject> {
STATIC_ASSERT(kArrayIndexLengthBits > 0); STATIC_ASSERT(kArrayIndexLengthBits > 0);
STATIC_ASSERT(kMaxArrayIndexSize < (1 << kArrayIndexLengthBits)); STATIC_ASSERT(kMaxArrayIndexSize < (1 << kArrayIndexLengthBits));
class ArrayIndexValueBits using ArrayIndexValueBits =
: public BitField<unsigned int, kNofHashBitFields, kArrayIndexValueBits> { BitField<unsigned int, kNofHashBitFields, kArrayIndexValueBits>;
}; // NOLINT using ArrayIndexLengthBits =
class ArrayIndexLengthBits BitField<unsigned int, kNofHashBitFields + kArrayIndexValueBits,
: public BitField<unsigned int, kNofHashBitFields + kArrayIndexValueBits, kArrayIndexLengthBits>;
kArrayIndexLengthBits> {}; // NOLINT
// Check that kMaxCachedArrayIndexLength + 1 is a power of two so we // Check that kMaxCachedArrayIndexLength + 1 is a power of two so we
// could use a mask to test if the length of string is less than or equal to // could use a mask to test if the length of string is less than or equal to
......
...@@ -61,10 +61,10 @@ class PropertyArray : public HeapObject { ...@@ -61,10 +61,10 @@ class PropertyArray : public HeapObject {
using BodyDescriptor = FlexibleBodyDescriptor<kHeaderSize>; using BodyDescriptor = FlexibleBodyDescriptor<kHeaderSize>;
static const int kLengthFieldSize = 10; static const int kLengthFieldSize = 10;
class LengthField : public BitField<int, 0, kLengthFieldSize> {}; using LengthField = BitField<int, 0, kLengthFieldSize>;
static const int kMaxLength = LengthField::kMax; static const int kMaxLength = LengthField::kMax;
class HashField : public BitField<int, kLengthFieldSize, using HashField =
kSmiValueSize - kLengthFieldSize - 1> {}; BitField<int, kLengthFieldSize, kSmiValueSize - kLengthFieldSize - 1>;
static const int kNoHashSentinel = 0; static const int kNoHashSentinel = 0;
......
...@@ -310,13 +310,11 @@ class PropertyDetails { ...@@ -310,13 +310,11 @@ class PropertyDetails {
// Bit fields in value_ (type, shift, size). Must be public so the // Bit fields in value_ (type, shift, size). Must be public so the
// constants can be embedded in generated code. // constants can be embedded in generated code.
class KindField : public BitField<PropertyKind, 0, 1> {}; using KindField = BitField<PropertyKind, 0, 1>;
class LocationField : public BitField<PropertyLocation, KindField::kNext, 1> { using LocationField = BitField<PropertyLocation, KindField::kNext, 1>;
}; using ConstnessField = BitField<PropertyConstness, LocationField::kNext, 1>;
class ConstnessField using AttributesField =
: public BitField<PropertyConstness, LocationField::kNext, 1> {}; BitField<PropertyAttributes, ConstnessField::kNext, 3>;
class AttributesField
: public BitField<PropertyAttributes, ConstnessField::kNext, 3> {};
static const int kAttributesReadOnlyMask = static const int kAttributesReadOnlyMask =
(READ_ONLY << AttributesField::kShift); (READ_ONLY << AttributesField::kShift);
static const int kAttributesDontDeleteMask = static const int kAttributesDontDeleteMask =
...@@ -325,20 +323,17 @@ class PropertyDetails { ...@@ -325,20 +323,17 @@ class PropertyDetails {
(DONT_ENUM << AttributesField::kShift); (DONT_ENUM << AttributesField::kShift);
// Bit fields for normalized objects. // Bit fields for normalized objects.
class PropertyCellTypeField using PropertyCellTypeField =
: public BitField<PropertyCellType, AttributesField::kNext, 2> {}; BitField<PropertyCellType, AttributesField::kNext, 2>;
class DictionaryStorageField using DictionaryStorageField =
: public BitField<uint32_t, PropertyCellTypeField::kNext, 23> {}; BitField<uint32_t, PropertyCellTypeField::kNext, 23>;
// Bit fields for fast objects. // Bit fields for fast objects.
class RepresentationField using RepresentationField = BitField<uint32_t, AttributesField::kNext, 3>;
: public BitField<uint32_t, AttributesField::kNext, 3> {}; using DescriptorPointer =
class DescriptorPointer BitField<uint32_t, RepresentationField::kNext, kDescriptorIndexBitCount>;
: public BitField<uint32_t, RepresentationField::kNext, using FieldIndexField =
kDescriptorIndexBitCount> {}; // NOLINT BitField<uint32_t, DescriptorPointer::kNext, kDescriptorIndexBitCount>;
class FieldIndexField : public BitField<uint32_t, DescriptorPointer::kNext,
kDescriptorIndexBitCount> {
}; // NOLINT
// All bits for both fast and slow objects must fit in a smi. // All bits for both fast and slow objects must fit in a smi.
STATIC_ASSERT(DictionaryStorageField::kNext <= 31); STATIC_ASSERT(DictionaryStorageField::kNext <= 31);
......
...@@ -224,39 +224,32 @@ class ScopeInfo : public FixedArray { ...@@ -224,39 +224,32 @@ class ScopeInfo : public FixedArray {
enum VariableAllocationInfo { NONE, STACK, CONTEXT, UNUSED }; enum VariableAllocationInfo { NONE, STACK, CONTEXT, UNUSED };
// Properties of scopes. // Properties of scopes.
class ScopeTypeField : public BitField<ScopeType, 0, 4> {}; using ScopeTypeField = BitField<ScopeType, 0, 4>;
class CallsSloppyEvalField : public BitField<bool, ScopeTypeField::kNext, 1> { using CallsSloppyEvalField = BitField<bool, ScopeTypeField::kNext, 1>;
};
STATIC_ASSERT(LanguageModeSize == 2); STATIC_ASSERT(LanguageModeSize == 2);
class LanguageModeField using LanguageModeField =
: public BitField<LanguageMode, CallsSloppyEvalField::kNext, 1> {}; BitField<LanguageMode, CallsSloppyEvalField::kNext, 1>;
class DeclarationScopeField using DeclarationScopeField = BitField<bool, LanguageModeField::kNext, 1>;
: public BitField<bool, LanguageModeField::kNext, 1> {}; using ReceiverVariableField =
class ReceiverVariableField BitField<VariableAllocationInfo, DeclarationScopeField::kNext, 2>;
: public BitField<VariableAllocationInfo, DeclarationScopeField::kNext, using HasClassBrandField = BitField<bool, ReceiverVariableField::kNext, 1>;
2> {}; using HasNewTargetField = BitField<bool, HasClassBrandField::kNext, 1>;
class HasClassBrandField using FunctionVariableField =
: public BitField<bool, ReceiverVariableField::kNext, 1> {}; BitField<VariableAllocationInfo, HasNewTargetField::kNext, 2>;
class HasNewTargetField
: public BitField<bool, HasClassBrandField::kNext, 1> {};
class FunctionVariableField
: public BitField<VariableAllocationInfo, HasNewTargetField::kNext, 2> {};
// TODO(cbruni): Combine with function variable field when only storing the // TODO(cbruni): Combine with function variable field when only storing the
// function name. // function name.
class HasInferredFunctionNameField using HasInferredFunctionNameField =
: public BitField<bool, FunctionVariableField::kNext, 1> {}; BitField<bool, FunctionVariableField::kNext, 1>;
class IsAsmModuleField using IsAsmModuleField =
: public BitField<bool, HasInferredFunctionNameField::kNext, 1> {}; BitField<bool, HasInferredFunctionNameField::kNext, 1>;
class HasSimpleParametersField using HasSimpleParametersField = BitField<bool, IsAsmModuleField::kNext, 1>;
: public BitField<bool, IsAsmModuleField::kNext, 1> {}; using FunctionKindField =
class FunctionKindField BitField<FunctionKind, HasSimpleParametersField::kNext, 5>;
: public BitField<FunctionKind, HasSimpleParametersField::kNext, 5> {}; using HasOuterScopeInfoField = BitField<bool, FunctionKindField::kNext, 1>;
class HasOuterScopeInfoField using IsDebugEvaluateScopeField =
: public BitField<bool, FunctionKindField::kNext, 1> {}; BitField<bool, HasOuterScopeInfoField::kNext, 1>;
class IsDebugEvaluateScopeField using ForceContextAllocationField =
: public BitField<bool, HasOuterScopeInfoField::kNext, 1> {}; BitField<bool, IsDebugEvaluateScopeField::kNext, 1>;
class ForceContextAllocationField
: public BitField<bool, IsDebugEvaluateScopeField::kNext, 1> {};
STATIC_ASSERT(kLastFunctionKind <= FunctionKindField::kMax); STATIC_ASSERT(kLastFunctionKind <= FunctionKindField::kMax);
...@@ -323,14 +316,13 @@ class ScopeInfo : public FixedArray { ...@@ -323,14 +316,13 @@ class ScopeInfo : public FixedArray {
static const int kPositionInfoEntries = 2; static const int kPositionInfoEntries = 2;
// Properties of variables. // Properties of variables.
class VariableModeField : public BitField<VariableMode, 0, 3> {}; using VariableModeField = BitField<VariableMode, 0, 3>;
class InitFlagField : public BitField<InitializationFlag, 3, 1> {}; using InitFlagField = BitField<InitializationFlag, 3, 1>;
class MaybeAssignedFlagField : public BitField<MaybeAssignedFlag, 4, 1> {}; using MaybeAssignedFlagField = BitField<MaybeAssignedFlag, 4, 1>;
class RequiresBrandCheckField using RequiresBrandCheckField =
: public BitField<RequiresBrandCheckFlag, MaybeAssignedFlagField::kNext, BitField<RequiresBrandCheckFlag, MaybeAssignedFlagField::kNext, 1>;
1> {}; using ParameterNumberField =
class ParameterNumberField BitField<uint32_t, RequiresBrandCheckField::kNext, 16>;
: public BitField<uint32_t, RequiresBrandCheckField::kNext, 16> {};
friend class ScopeIterator; friend class ScopeIterator;
friend std::ostream& operator<<(std::ostream& os, friend std::ostream& operator<<(std::ostream& os,
......
...@@ -227,9 +227,8 @@ class ObjectTemplateInfo : public TemplateInfo { ...@@ -227,9 +227,8 @@ class ObjectTemplateInfo : public TemplateInfo {
inline ObjectTemplateInfo GetParent(Isolate* isolate); inline ObjectTemplateInfo GetParent(Isolate* isolate);
private: private:
class IsImmutablePrototype : public BitField<bool, 0, 1> {}; using IsImmutablePrototype = BitField<bool, 0, 1>;
class EmbedderFieldCount using EmbedderFieldCount = BitField<int, IsImmutablePrototype::kNext, 29>;
: public BitField<int, IsImmutablePrototype::kNext, 29> {};
OBJECT_CONSTRUCTORS(ObjectTemplateInfo, TemplateInfo); OBJECT_CONSTRUCTORS(ObjectTemplateInfo, TemplateInfo);
}; };
......
...@@ -21,22 +21,21 @@ namespace internal { ...@@ -21,22 +21,21 @@ namespace internal {
namespace { namespace {
class ScopeCallsSloppyEvalField : public BitField8<bool, 0, 1> {}; using ScopeCallsSloppyEvalField = BitField8<bool, 0, 1>;
class InnerScopeCallsEvalField using InnerScopeCallsEvalField =
: public BitField8<bool, ScopeCallsSloppyEvalField::kNext, 1> {}; BitField8<bool, ScopeCallsSloppyEvalField::kNext, 1>;
class VariableMaybeAssignedField : public BitField8<bool, 0, 1> {}; using VariableMaybeAssignedField = BitField8<bool, 0, 1>;
class VariableContextAllocatedField using VariableContextAllocatedField =
: public BitField8<bool, VariableMaybeAssignedField::kNext, 1> {}; BitField8<bool, VariableMaybeAssignedField::kNext, 1>;
class HasDataField : public BitField<bool, 0, 1> {}; using HasDataField = BitField<bool, 0, 1>;
class LengthEqualsParametersField using LengthEqualsParametersField = BitField<bool, HasDataField::kNext, 1>;
: public BitField<bool, HasDataField::kNext, 1> {}; using NumberOfParametersField =
class NumberOfParametersField BitField<uint16_t, LengthEqualsParametersField::kNext, 16>;
: public BitField<uint16_t, LengthEqualsParametersField::kNext, 16> {};
using LanguageField = BitField8<LanguageMode, 0, 1>;
class LanguageField : public BitField8<LanguageMode, 0, 1> {}; using UsesSuperField = BitField8<bool, LanguageField::kNext, 1>;
class UsesSuperField : public BitField8<bool, LanguageField::kNext, 1> {};
STATIC_ASSERT(LanguageModeSize <= LanguageField::kNumValues); STATIC_ASSERT(LanguageModeSize <= LanguageField::kNumValues);
} // namespace } // namespace
......
...@@ -215,8 +215,8 @@ class V8_EXPORT_PRIVATE Token { ...@@ -215,8 +215,8 @@ class V8_EXPORT_PRIVATE Token {
return name_[token]; return name_[token];
} }
class IsKeywordBits : public BitField8<bool, 0, 1> {}; using IsKeywordBits = BitField8<bool, 0, 1>;
class IsPropertyNameBits : public BitField8<bool, IsKeywordBits::kNext, 1> {}; using IsPropertyNameBits = BitField8<bool, IsKeywordBits::kNext, 1>;
// Predicates // Predicates
static bool IsKeyword(Value token) { static bool IsKeyword(Value token) {
......
...@@ -82,8 +82,8 @@ class HeapGraphEdge { ...@@ -82,8 +82,8 @@ class HeapGraphEdge {
V8_INLINE HeapSnapshot* snapshot() const; V8_INLINE HeapSnapshot* snapshot() const;
int from_index() const { return FromIndexField::decode(bit_field_); } int from_index() const { return FromIndexField::decode(bit_field_); }
class TypeField : public BitField<Type, 0, 3> {}; using TypeField = BitField<Type, 0, 3>;
class FromIndexField : public BitField<int, 3, 29> {}; using FromIndexField = BitField<int, 3, 29>;
uint32_t bit_field_; uint32_t bit_field_;
HeapEntry* to_entry_; HeapEntry* to_entry_;
union { union {
......
...@@ -769,11 +769,11 @@ V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, Runtime::FunctionId); ...@@ -769,11 +769,11 @@ V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, Runtime::FunctionId);
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Constants used by interface to runtime functions. // Constants used by interface to runtime functions.
class AllocateDoubleAlignFlag : public BitField<bool, 0, 1> {}; using AllocateDoubleAlignFlag = BitField<bool, 0, 1>;
class AllowLargeObjectAllocationFlag : public BitField<bool, 1, 1> {}; using AllowLargeObjectAllocationFlag = BitField<bool, 1, 1>;
class DeclareGlobalsEvalFlag : public BitField<bool, 0, 1> {}; using DeclareGlobalsEvalFlag = BitField<bool, 0, 1>;
// A set of bits returned by Runtime_GetOptimizationStatus. // A set of bits returned by Runtime_GetOptimizationStatus.
// These bits must be in sync with bits defined in test/mjsunit/mjsunit.js // These bits must be in sync with bits defined in test/mjsunit/mjsunit.js
......
...@@ -154,12 +154,11 @@ class SerializerReference { ...@@ -154,12 +154,11 @@ class SerializerReference {
} }
private: private:
class SpaceBits : public BitField<SnapshotSpace, 0, kSpaceTagSize> {}; using SpaceBits = BitField<SnapshotSpace, 0, kSpaceTagSize>;
class ChunkIndexBits using ChunkIndexBits =
: public BitField<uint32_t, SpaceBits::kNext, 32 - kSpaceTagSize> {}; BitField<uint32_t, SpaceBits::kNext, 32 - kSpaceTagSize>;
class SpecialValueTypeBits using SpecialValueTypeBits =
: public BitField<SpecialValueType, SpaceBits::kNext, BitField<SpecialValueType, SpaceBits::kNext, 32 - kSpaceTagSize>;
32 - kSpaceTagSize> {};
// We use two fields to store a reference. // We use two fields to store a reference.
// In case of a normal back reference, the bitfield_ stores the space and // In case of a normal back reference, the bitfield_ stores the space and
......
...@@ -34,8 +34,8 @@ class ExternalReferenceEncoder { ...@@ -34,8 +34,8 @@ class ExternalReferenceEncoder {
uint32_t index() const { return Index::decode(value_); } uint32_t index() const { return Index::decode(value_); }
private: private:
class Index : public BitField<uint32_t, 0, 31> {}; using Index = BitField<uint32_t, 0, 31>;
class IsFromAPI : public BitField<bool, 31, 1> {}; using IsFromAPI = BitField<bool, 31, 1>;
uint32_t value_; uint32_t value_;
}; };
...@@ -328,8 +328,8 @@ class SerializedData { ...@@ -328,8 +328,8 @@ class SerializedData {
uint32_t GetMagicNumber() const { return GetHeaderValue(kMagicNumberOffset); } uint32_t GetMagicNumber() const { return GetHeaderValue(kMagicNumberOffset); }
class ChunkSizeBits : public BitField<uint32_t, 0, 31> {}; using ChunkSizeBits = BitField<uint32_t, 0, 31>;
class IsLastChunkBits : public BitField<bool, 31, 1> {}; using IsLastChunkBits = BitField<bool, 31, 1>;
static constexpr uint32_t kMagicNumberOffset = 0; static constexpr uint32_t kMagicNumberOffset = 0;
static constexpr uint32_t kMagicNumber = static constexpr uint32_t kMagicNumber =
......
...@@ -51,8 +51,8 @@ class Predicate { ...@@ -51,8 +51,8 @@ class Predicate {
bool value() const { return ValueField::decode(bit_field_); } bool value() const { return ValueField::decode(bit_field_); }
private: private:
class CodePointField : public v8::internal::BitField<uchar, 0, 21> {}; using CodePointField = v8::internal::BitField<uchar, 0, 21>;
class ValueField : public v8::internal::BitField<bool, 21, 1> {}; using ValueField = v8::internal::BitField<bool, 21, 1>;
uint32_t bit_field_; uint32_t bit_field_;
}; };
......
...@@ -302,9 +302,12 @@ T SaturateSub(T a, T b) { ...@@ -302,9 +302,12 @@ T SaturateSub(T a, T b) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// BitField is a help template for encoding and decode bitfield with // BitField is a help template for encoding and decode bitfield with
// unsigned content. // unsigned content.
// Instantiate them via 'using', which is cheaper than deriving a new class:
// using MyBitField = BitField<int, 4, 2, MyEnum>;
// The BitField class is final to enforce this style over derivation.
template <class T, int shift, int size, class U = uint32_t> template <class T, int shift, int size, class U = uint32_t>
class BitField { class BitField final {
public: public:
STATIC_ASSERT(std::is_unsigned<U>::value); STATIC_ASSERT(std::is_unsigned<U>::value);
STATIC_ASSERT(shift < 8 * sizeof(U)); // Otherwise shifts by {shift} are UB. STATIC_ASSERT(shift < 8 * sizeof(U)); // Otherwise shifts by {shift} are UB.
......
...@@ -524,9 +524,9 @@ class CompilationStateImpl { ...@@ -524,9 +524,9 @@ class CompilationStateImpl {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Encoding of fields in the {compilation_progress_} vector. // Encoding of fields in the {compilation_progress_} vector.
class RequiredBaselineTierField : public BitField8<ExecutionTier, 0, 2> {}; using RequiredBaselineTierField = BitField8<ExecutionTier, 0, 2>;
class RequiredTopTierField : public BitField8<ExecutionTier, 2, 2> {}; using RequiredTopTierField = BitField8<ExecutionTier, 2, 2>;
class ReachedTierField : public BitField8<ExecutionTier, 4, 2> {}; using ReachedTierField = BitField8<ExecutionTier, 4, 2>;
}; };
CompilationStateImpl* Impl(CompilationState* compilation_state) { CompilationStateImpl* Impl(CompilationState* compilation_state) {
......
...@@ -311,7 +311,7 @@ TEST(DecodeWordFromWord32) { ...@@ -311,7 +311,7 @@ TEST(DecodeWordFromWord32) {
CodeAssemblerTester asm_tester(isolate); CodeAssemblerTester asm_tester(isolate);
CodeStubAssembler m(asm_tester.state()); CodeStubAssembler m(asm_tester.state());
class TestBitField : public BitField<unsigned, 3, 3> {}; using TestBitField = BitField<unsigned, 3, 3>;
m.Return(m.SmiTag( m.Return(m.SmiTag(
m.Signed(m.DecodeWordFromWord32<TestBitField>(m.Int32Constant(0x2F))))); m.Signed(m.DecodeWordFromWord32<TestBitField>(m.Int32Constant(0x2F)))));
FunctionTester ft(asm_tester.GenerateCode()); FunctionTester ft(asm_tester.GenerateCode());
......
...@@ -312,11 +312,10 @@ TEST(ExponentNumberStr) { ...@@ -312,11 +312,10 @@ TEST(ExponentNumberStr) {
CHECK_EQ(1e-106, StringToDouble(".000001e-100", NO_FLAGS)); CHECK_EQ(1e-106, StringToDouble(".000001e-100", NO_FLAGS));
} }
using OneBit1 = BitField<uint32_t, 0, 1>;
class OneBit1: public BitField<uint32_t, 0, 1> {}; using OneBit2 = BitField<uint32_t, 7, 1>;
class OneBit2: public BitField<uint32_t, 7, 1> {}; using EightBit1 = BitField<uint32_t, 0, 8>;
class EightBit1: public BitField<uint32_t, 0, 8> {}; using EightBit2 = BitField<uint32_t, 13, 8>;
class EightBit2: public BitField<uint32_t, 13, 8> {};
TEST(BitField) { TEST(BitField) {
uint32_t x; uint32_t x;
...@@ -351,9 +350,8 @@ TEST(BitField) { ...@@ -351,9 +350,8 @@ TEST(BitField) {
CHECK(!EightBit2::is_valid(256)); CHECK(!EightBit2::is_valid(256));
} }
using UpperBits = BitField64<int, 61, 3>;
class UpperBits: public BitField64<int, 61, 3> {}; using MiddleBits = BitField64<int, 31, 2>;
class MiddleBits: public BitField64<int, 31, 2> {};
TEST(BitField64) { TEST(BitField64) {
uint64_t x; uint64_t x;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment