Commit 753a07db authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

Revert "[utils] Make BitField final"

This reverts commit 658ff200.

Reason for revert: Fails no-i18n bot: https://ci.chromium.org/p/v8/builders/ci/V8%20Linux%20-%20noi18n%20-%20debug/27826

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}

TBR=yangguo@chromium.org,clemensh@chromium.org

Change-Id: I50234a09c77aa89fdcf1e01c2497cc08d3ac79a8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:9396, v8:7629
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1724377Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62958}
parent b8a50cf7
This diff is collapsed.
...@@ -243,21 +243,25 @@ class Variable final : public ZoneObject { ...@@ -243,21 +243,25 @@ class Variable final : public ZoneObject {
bit_field_ = MaybeAssignedFlagField::update(bit_field_, kMaybeAssigned); bit_field_ = MaybeAssignedFlagField::update(bit_field_, kMaybeAssigned);
} }
using VariableModeField = BitField16<VariableMode, 0, 3>; class VariableModeField : public BitField16<VariableMode, 0, 3> {};
using VariableKindField = class VariableKindField
BitField16<VariableKind, VariableModeField::kNext, 3>; : public BitField16<VariableKind, VariableModeField::kNext, 3> {};
using LocationField = class LocationField
BitField16<VariableLocation, VariableKindField::kNext, 3>; : public BitField16<VariableLocation, VariableKindField::kNext, 3> {};
using ForceContextAllocationField = BitField16<bool, LocationField::kNext, 1>; class ForceContextAllocationField
using IsUsedField = BitField16<bool, ForceContextAllocationField::kNext, 1>; : public BitField16<bool, LocationField::kNext, 1> {};
using InitializationFlagField = class IsUsedField
BitField16<InitializationFlag, IsUsedField::kNext, 1>; : public BitField16<bool, ForceContextAllocationField::kNext, 1> {};
using ForceHoleInitializationField = class InitializationFlagField
BitField16<bool, InitializationFlagField::kNext, 1>; : public BitField16<InitializationFlag, IsUsedField::kNext, 1> {};
using MaybeAssignedFlagField = class ForceHoleInitializationField
BitField16<MaybeAssignedFlag, ForceHoleInitializationField::kNext, 1>; : public BitField16<bool, InitializationFlagField::kNext, 1> {};
using RequiresBrandCheckField = class MaybeAssignedFlagField
BitField16<RequiresBrandCheckFlag, MaybeAssignedFlagField::kNext, 1>; : public BitField16<MaybeAssignedFlag,
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);
} }
using FastElementsField = BitField<bool, 0, 1>; class FastElementsField : public BitField<bool, 0, 1> {};
using ExceedsLimitField = BitField<bool, 1, 1>; class ExceedsLimitField : public BitField<bool, 1, 1> {};
using IsFixedArrayField = BitField<bool, 2, 1>; class IsFixedArrayField : public BitField<bool, 2, 1> {};
using HasSimpleElementsField = BitField<bool, 3, 1>; class HasSimpleElementsField : public 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.
using HandlerPredictionField = BitField<CatchPrediction, 0, 3>; class HandlerPredictionField : public BitField<CatchPrediction, 0, 3> {};
using HandlerOffsetField = BitField<int, 3, 29>; class HandlerOffsetField : public 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_;
using TypeField = BitField<Type, 0, 2>; class TypeField : public BitField<Type, 0, 2> {};
using NextField = BitField<int, 2, 32 - 2>; class NextField : public 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.
using MoreBit = BitField8<bool, 7, 1>; class MoreBit : public BitField8<bool, 7, 1> {};
using ValueBits = BitField8<unsigned, 0, 7>; class ValueBits : public 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,18 +92,16 @@ bool PerThreadAssertScope<kType, kAllow>::IsAllowed() { ...@@ -92,18 +92,16 @@ bool PerThreadAssertScope<kType, kAllow>::IsAllowed() {
return current_data == nullptr || current_data->Get(kType); return current_data == nullptr || current_data->Get(kType);
} }
namespace { template <PerIsolateAssertType kType, bool kAllow>
template <PerIsolateAssertType kType> class PerIsolateAssertScope<kType, kAllow>::DataBit
using DataBit = BitField<bool, kType, 1>; : public 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( isolate_->set_per_isolate_assert_data(DataBit::update(old_data_, kAllow));
DataBit<kType>::update(old_data_, kAllow));
} }
template <PerIsolateAssertType kType, bool kAllow> template <PerIsolateAssertType kType, bool kAllow>
...@@ -114,7 +112,7 @@ PerIsolateAssertScope<kType, kAllow>::~PerIsolateAssertScope() { ...@@ -114,7 +112,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<kType>::decode(isolate->per_isolate_assert_data()); return DataBit::decode(isolate->per_isolate_assert_data());
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -81,6 +81,8 @@ class PerIsolateAssertScope { ...@@ -81,6 +81,8 @@ 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;
using KindField = BitField64<Kind, 0, 3>; class KindField : public 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);
using VirtualRegisterField = BitField64<uint32_t, 3, 32>; class VirtualRegisterField : public BitField64<uint32_t, 3, 32> {};
// BitFields for all unallocated operands. // BitFields for all unallocated operands.
using BasicPolicyField = BitField64<BasicPolicy, 35, 1>; class BasicPolicyField : public BitField64<BasicPolicy, 35, 1> {};
// BitFields specific to BasicPolicy::FIXED_SLOT. // BitFields specific to BasicPolicy::FIXED_SLOT.
using FixedSlotIndexField = BitField64<int, 36, 28>; class FixedSlotIndexField : public BitField64<int, 36, 28> {};
// BitFields specific to BasicPolicy::EXTENDED_POLICY. // BitFields specific to BasicPolicy::EXTENDED_POLICY.
using ExtendedPolicyField = BitField64<ExtendedPolicy, 36, 3>; class ExtendedPolicyField : public BitField64<ExtendedPolicy, 36, 3> {};
using LifetimeField = BitField64<Lifetime, 39, 1>; class LifetimeField : public BitField64<Lifetime, 39, 1> {};
using HasSecondaryStorageField = BitField64<bool, 40, 1>; class HasSecondaryStorageField : public BitField64<bool, 40, 1> {};
using FixedRegisterField = BitField64<int, 41, 6>; class FixedRegisterField : public BitField64<int, 41, 6> {};
using SecondaryStorageField = BitField64<int, 47, 3>; class SecondaryStorageField : public 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);
using VirtualRegisterField = BitField64<uint32_t, 3, 32>; class VirtualRegisterField : public 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);
using TypeField = BitField64<ImmediateType, 3, 1>; class TypeField : public BitField64<ImmediateType, 3, 1> {};
using ValueField = BitField64<int32_t, 32, 32>; class ValueField : public 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);
using LocationKindField = BitField64<LocationKind, 3, 2>; class LocationKindField : public BitField64<LocationKind, 3, 2> {};
using RepresentationField = BitField64<MachineRepresentation, 5, 8>; class RepresentationField : public BitField64<MachineRepresentation, 5, 8> {};
using IndexField = BitField64<int32_t, 35, 29>; class IndexField : public 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 };
using TypeField = BitField<LocationType, 0, 1>; class TypeField : public BitField<LocationType, 0, 1> {};
using LocationField = BitField<int32_t, TypeField::kNext, 31>; class LocationField : public 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,9 +580,10 @@ class GlobalHandles::Node final : public NodeBase<GlobalHandles::Node> { ...@@ -580,9 +580,10 @@ 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.
using NodeState = BitField8<State, 0, 3>; class NodeState : public BitField8<State, 0, 3> {};
using IsInYoungList = BitField8<bool, NodeState::kNext, 1>; class IsInYoungList : public BitField8<bool, NodeState::kNext, 1> {};
using NodeWeaknessType = BitField8<WeaknessType, IsInYoungList::kNext, 2>; class NodeWeaknessType
: 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_;
...@@ -649,9 +650,9 @@ class GlobalHandles::TracedNode final ...@@ -649,9 +650,9 @@ class GlobalHandles::TracedNode final
} }
protected: protected:
using NodeState = BitField8<State, 0, 2>; class NodeState : public BitField8<State, 0, 2> {};
using IsInYoungList = BitField8<bool, NodeState::kNext, 1>; class IsInYoungList : public BitField8<bool, NodeState::kNext, 1> {};
using IsRoot = BitField8<bool, IsInYoungList::kNext, 1>; class IsRoot : public 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:
using OffsetField = BitField<int, 0, 29>; class OffsetField : public BitField<int, 0, 29> {};
using TypeField = BitField<SlotType, 29, 3>; class TypeField : public BitField<SlotType, 29, 3> {};
struct TypedSlot { struct TypedSlot {
uint32_t type_and_offset; uint32_t type_and_offset;
}; };
......
...@@ -47,60 +47,65 @@ class LoadHandler final : public DataHandler { ...@@ -47,60 +47,65 @@ class LoadHandler final : public DataHandler {
kNonExistent, kNonExistent,
kModuleExport kModuleExport
}; };
using KindBits = BitField<Kind, 0, 4>; class KindBits : public 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.
using DoAccessCheckOnReceiverBits = BitField<bool, KindBits::kNext, 1>; class DoAccessCheckOnReceiverBits
: 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.
using LookupOnReceiverBits = class LookupOnReceiverBits
BitField<bool, DoAccessCheckOnReceiverBits::kNext, 1>; : public 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.
using DescriptorBits = class DescriptorBits : public BitField<unsigned, LookupOnReceiverBits::kNext,
BitField<unsigned, LookupOnReceiverBits::kNext, kDescriptorIndexBitCount>; 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.
// //
using IsInobjectBits = BitField<bool, LookupOnReceiverBits::kNext, 1>; class IsInobjectBits : public 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.
using FieldIndexBits = class FieldIndexBits : public BitField<unsigned, IsDoubleBits::kNext,
BitField<unsigned, IsDoubleBits::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);
// //
// Encoding when KindBits contains kElement or kIndexedString. // Encoding when KindBits contains kElement or kIndexedString.
// //
using AllowOutOfBoundsBits = BitField<bool, LookupOnReceiverBits::kNext, 1>; class AllowOutOfBoundsBits
: public BitField<bool, LookupOnReceiverBits::kNext, 1> {};
// //
// Encoding when KindBits contains kElement. // Encoding when KindBits contains kElement.
// //
using IsJsArrayBits = BitField<bool, AllowOutOfBoundsBits::kNext, 1>; class IsJsArrayBits : public BitField<bool, AllowOutOfBoundsBits::kNext, 1> {
using ConvertHoleBits = BitField<bool, IsJsArrayBits::kNext, 1>; };
using ElementsKindBits = BitField<ElementsKind, ConvertHoleBits::kNext, 8>; class ConvertHoleBits : public BitField<bool, IsJsArrayBits::kNext, 1> {};
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.
// //
using ExportsIndexBits = class ExportsIndexBits
BitField<unsigned, LookupOnReceiverBits::kNext, : public 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);
...@@ -201,27 +206,28 @@ class StoreHandler final : public DataHandler { ...@@ -201,27 +206,28 @@ class StoreHandler final : public DataHandler {
kProxy, kProxy,
kKindsNumber // Keep last kKindsNumber // Keep last
}; };
using KindBits = BitField<Kind, 0, 4>; class KindBits : public 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.
using DoAccessCheckOnReceiverBits = BitField<bool, KindBits::kNext, 1>; class DoAccessCheckOnReceiverBits
: 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.
using LookupOnReceiverBits = class LookupOnReceiverBits
BitField<bool, DoAccessCheckOnReceiverBits::kNext, 1>; : public 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.
using DescriptorBits = class DescriptorBits : public BitField<unsigned, LookupOnReceiverBits::kNext,
BitField<unsigned, LookupOnReceiverBits::kNext, kDescriptorIndexBitCount>; kDescriptorIndexBitCount> {};
// //
// Encoding when KindBits contains kTransitionToConstant. // Encoding when KindBits contains kTransitionToConstant.
// //
...@@ -232,12 +238,13 @@ class StoreHandler final : public DataHandler { ...@@ -232,12 +238,13 @@ class StoreHandler final : public DataHandler {
// //
// Encoding when KindBits contains kField or kTransitionToField. // Encoding when KindBits contains kField or kTransitionToField.
// //
using IsInobjectBits = BitField<bool, DescriptorBits::kNext, 1>; class IsInobjectBits : public BitField<bool, DescriptorBits::kNext, 1> {};
using FieldRepresentationBits = class FieldRepresentationBits
BitField<FieldRepresentation, IsInobjectBits::kNext, 2>; : public 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.
using FieldIndexBits = BitField<unsigned, FieldRepresentationBits::kNext, class FieldIndexBits
kDescriptorIndexBitCount + 1>; : public BitField<unsigned, FieldRepresentationBits::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);
......
...@@ -18,8 +18,8 @@ namespace interpreter { ...@@ -18,8 +18,8 @@ namespace interpreter {
class CreateArrayLiteralFlags { class CreateArrayLiteralFlags {
public: public:
using FlagsBits = BitField8<int, 0, 5>; class FlagsBits : public BitField8<int, 0, 5> {};
using FastCloneSupportedBit = BitField8<bool, FlagsBits::kNext, 1>; class FastCloneSupportedBit : public 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:
using FlagsBits = BitField8<int, 0, 5>; class FlagsBits : public BitField8<int, 0, 5> {};
using FastCloneSupportedBit = BitField8<bool, FlagsBits::kNext, 1>; class FastCloneSupportedBit : public 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:
using PretenuredBit = BitField8<bool, 0, 1>; class PretenuredBit : public BitField8<bool, 0, 1> {};
using FastNewClosureBit = BitField8<bool, PretenuredBit::kNext, 1>; class FastNewClosureBit : public 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,8 +80,9 @@ class TestTypeOfFlags { ...@@ -80,8 +80,9 @@ class TestTypeOfFlags {
class StoreLookupSlotFlags { class StoreLookupSlotFlags {
public: public:
using LanguageModeBit = BitField8<LanguageMode, 0, 1>; class LanguageModeBit : public BitField8<LanguageMode, 0, 1> {};
using LookupHoistingModeBit = BitField8<bool, LanguageModeBit::kNext, 1>; class LookupHoistingModeBit
: 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.
using ElementsKindBits = BitField<ElementsKind, 0, 5>; class ElementsKindBits : public BitField<ElementsKind, 0, 5> {};
using DoNotInlineBit = BitField<bool, 5, 1>; class DoNotInlineBit : public BitField<bool, 5, 1> {};
// Unused bits 6-30. // Unused bits 6-30.
// Bitfields for pretenure_data // Bitfields for pretenure_data
using MementoFoundCountBits = BitField<int, 0, 26>; class MementoFoundCountBits : public BitField<int, 0, 26> {};
using PretenureDecisionBits = BitField<PretenureDecision, 26, 3>; class PretenureDecisionBits : public BitField<PretenureDecision, 26, 3> {};
using DeoptDependentCodeBit = BitField<bool, 29, 1>; class DeoptDependentCodeBit : public 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));
using SignBits = BitField<bool, 0, 1>; class SignBits : public BitField<bool, 0, 1> {};
using LengthBits = BitField<int, SignBits::kNext, kLengthFieldBits>; class LengthBits : public 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);
using GroupField = BitField<int, 0, 3>; class GroupField : public BitField<int, 0, 3> {};
using CountField = BitField<int, 3, 27>; class CountField : public 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,16 +107,17 @@ class FieldIndex final { ...@@ -107,16 +107,17 @@ class FieldIndex final {
(kDescriptorIndexBitCount + 1 + kTaggedSizeLog2); (kDescriptorIndexBitCount + 1 + kTaggedSizeLog2);
// Index from beginning of object. // Index from beginning of object.
using OffsetBits = BitField64<int, 0, kOffsetBitsSize>; class OffsetBits : public BitField64<int, 0, kOffsetBitsSize> {};
using IsInObjectBits = BitField64<bool, OffsetBits::kNext, 1>; class IsInObjectBits : public BitField64<bool, OffsetBits::kNext, 1> {};
using EncodingBits = BitField64<Encoding, IsInObjectBits::kNext, 2>; class EncodingBits : public BitField64<Encoding, IsInObjectBits::kNext, 2> {};
// Number of inobject properties. // Number of inobject properties.
using InObjectPropertyBits = class InObjectPropertyBits
BitField64<int, EncodingBits::kNext, kDescriptorIndexBitCount>; : public BitField64<int, EncodingBits::kNext, kDescriptorIndexBitCount> {
};
// Offset of first inobject property from beginning of object. // Offset of first inobject property from beginning of object.
using FirstInobjectPropertyOffsetBits = class FirstInobjectPropertyOffsetBits
BitField64<int, InObjectPropertyBits::kNext, : public 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;
using AsyncTaskIdField = BitField<int, kHandledHintBit + 1, 22>; class AsyncTaskIdField : public 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.
using ScheduledForCleanupField = BitField<bool, 0, 1>; class ScheduledForCleanupField : public BitField<bool, 0, 1> {};
OBJECT_CONSTRUCTORS(JSFinalizationGroup, JSObject); OBJECT_CONSTRUCTORS(JSFinalizationGroup, JSObject);
}; };
......
...@@ -99,11 +99,12 @@ class Name : public TorqueGeneratedName<Name, HeapObject> { ...@@ -99,11 +99,12 @@ class Name : public TorqueGeneratedName<Name, HeapObject> {
STATIC_ASSERT(kArrayIndexLengthBits > 0); STATIC_ASSERT(kArrayIndexLengthBits > 0);
STATIC_ASSERT(kMaxArrayIndexSize < (1 << kArrayIndexLengthBits)); STATIC_ASSERT(kMaxArrayIndexSize < (1 << kArrayIndexLengthBits));
using ArrayIndexValueBits = class ArrayIndexValueBits
BitField<unsigned int, kNofHashBitFields, kArrayIndexValueBits>; : public BitField<unsigned int, kNofHashBitFields, kArrayIndexValueBits> {
using ArrayIndexLengthBits = }; // NOLINT
BitField<unsigned int, kNofHashBitFields + kArrayIndexValueBits, class ArrayIndexLengthBits
kArrayIndexLengthBits>; : public BitField<unsigned int, kNofHashBitFields + kArrayIndexValueBits,
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;
using LengthField = BitField<int, 0, kLengthFieldSize>; class LengthField : public BitField<int, 0, kLengthFieldSize> {};
static const int kMaxLength = LengthField::kMax; static const int kMaxLength = LengthField::kMax;
using HashField = class HashField : public BitField<int, kLengthFieldSize,
BitField<int, kLengthFieldSize, kSmiValueSize - kLengthFieldSize - 1>; kSmiValueSize - kLengthFieldSize - 1> {};
static const int kNoHashSentinel = 0; static const int kNoHashSentinel = 0;
......
...@@ -310,11 +310,13 @@ class PropertyDetails { ...@@ -310,11 +310,13 @@ 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.
using KindField = BitField<PropertyKind, 0, 1>; class KindField : public BitField<PropertyKind, 0, 1> {};
using LocationField = BitField<PropertyLocation, KindField::kNext, 1>; class LocationField : public BitField<PropertyLocation, KindField::kNext, 1> {
using ConstnessField = BitField<PropertyConstness, LocationField::kNext, 1>; };
using AttributesField = class ConstnessField
BitField<PropertyAttributes, ConstnessField::kNext, 3>; : public BitField<PropertyConstness, LocationField::kNext, 1> {};
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 =
...@@ -323,17 +325,20 @@ class PropertyDetails { ...@@ -323,17 +325,20 @@ class PropertyDetails {
(DONT_ENUM << AttributesField::kShift); (DONT_ENUM << AttributesField::kShift);
// Bit fields for normalized objects. // Bit fields for normalized objects.
using PropertyCellTypeField = class PropertyCellTypeField
BitField<PropertyCellType, AttributesField::kNext, 2>; : public BitField<PropertyCellType, AttributesField::kNext, 2> {};
using DictionaryStorageField = class DictionaryStorageField
BitField<uint32_t, PropertyCellTypeField::kNext, 23>; : public BitField<uint32_t, PropertyCellTypeField::kNext, 23> {};
// Bit fields for fast objects. // Bit fields for fast objects.
using RepresentationField = BitField<uint32_t, AttributesField::kNext, 3>; class RepresentationField
using DescriptorPointer = : public BitField<uint32_t, AttributesField::kNext, 3> {};
BitField<uint32_t, RepresentationField::kNext, kDescriptorIndexBitCount>; class DescriptorPointer
using FieldIndexField = : public BitField<uint32_t, RepresentationField::kNext,
BitField<uint32_t, DescriptorPointer::kNext, kDescriptorIndexBitCount>; kDescriptorIndexBitCount> {}; // NOLINT
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,32 +224,39 @@ class ScopeInfo : public FixedArray { ...@@ -224,32 +224,39 @@ class ScopeInfo : public FixedArray {
enum VariableAllocationInfo { NONE, STACK, CONTEXT, UNUSED }; enum VariableAllocationInfo { NONE, STACK, CONTEXT, UNUSED };
// Properties of scopes. // Properties of scopes.
using ScopeTypeField = BitField<ScopeType, 0, 4>; class ScopeTypeField : public BitField<ScopeType, 0, 4> {};
using CallsSloppyEvalField = BitField<bool, ScopeTypeField::kNext, 1>; class CallsSloppyEvalField : public BitField<bool, ScopeTypeField::kNext, 1> {
};
STATIC_ASSERT(LanguageModeSize == 2); STATIC_ASSERT(LanguageModeSize == 2);
using LanguageModeField = class LanguageModeField
BitField<LanguageMode, CallsSloppyEvalField::kNext, 1>; : public BitField<LanguageMode, CallsSloppyEvalField::kNext, 1> {};
using DeclarationScopeField = BitField<bool, LanguageModeField::kNext, 1>; class DeclarationScopeField
using ReceiverVariableField = : public BitField<bool, LanguageModeField::kNext, 1> {};
BitField<VariableAllocationInfo, DeclarationScopeField::kNext, 2>; class ReceiverVariableField
using HasClassBrandField = BitField<bool, ReceiverVariableField::kNext, 1>; : public BitField<VariableAllocationInfo, DeclarationScopeField::kNext,
using HasNewTargetField = BitField<bool, HasClassBrandField::kNext, 1>; 2> {};
using FunctionVariableField = class HasClassBrandField
BitField<VariableAllocationInfo, HasNewTargetField::kNext, 2>; : public BitField<bool, ReceiverVariableField::kNext, 1> {};
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.
using HasInferredFunctionNameField = class HasInferredFunctionNameField
BitField<bool, FunctionVariableField::kNext, 1>; : public BitField<bool, FunctionVariableField::kNext, 1> {};
using IsAsmModuleField = class IsAsmModuleField
BitField<bool, HasInferredFunctionNameField::kNext, 1>; : public BitField<bool, HasInferredFunctionNameField::kNext, 1> {};
using HasSimpleParametersField = BitField<bool, IsAsmModuleField::kNext, 1>; class HasSimpleParametersField
using FunctionKindField = : public BitField<bool, IsAsmModuleField::kNext, 1> {};
BitField<FunctionKind, HasSimpleParametersField::kNext, 5>; class FunctionKindField
using HasOuterScopeInfoField = BitField<bool, FunctionKindField::kNext, 1>; : public BitField<FunctionKind, HasSimpleParametersField::kNext, 5> {};
using IsDebugEvaluateScopeField = class HasOuterScopeInfoField
BitField<bool, HasOuterScopeInfoField::kNext, 1>; : public BitField<bool, FunctionKindField::kNext, 1> {};
using ForceContextAllocationField = class IsDebugEvaluateScopeField
BitField<bool, IsDebugEvaluateScopeField::kNext, 1>; : public BitField<bool, HasOuterScopeInfoField::kNext, 1> {};
class ForceContextAllocationField
: public BitField<bool, IsDebugEvaluateScopeField::kNext, 1> {};
STATIC_ASSERT(kLastFunctionKind <= FunctionKindField::kMax); STATIC_ASSERT(kLastFunctionKind <= FunctionKindField::kMax);
...@@ -316,13 +323,14 @@ class ScopeInfo : public FixedArray { ...@@ -316,13 +323,14 @@ class ScopeInfo : public FixedArray {
static const int kPositionInfoEntries = 2; static const int kPositionInfoEntries = 2;
// Properties of variables. // Properties of variables.
using VariableModeField = BitField<VariableMode, 0, 3>; class VariableModeField : public BitField<VariableMode, 0, 3> {};
using InitFlagField = BitField<InitializationFlag, 3, 1>; class InitFlagField : public BitField<InitializationFlag, 3, 1> {};
using MaybeAssignedFlagField = BitField<MaybeAssignedFlag, 4, 1>; class MaybeAssignedFlagField : public BitField<MaybeAssignedFlag, 4, 1> {};
using RequiresBrandCheckField = class RequiresBrandCheckField
BitField<RequiresBrandCheckFlag, MaybeAssignedFlagField::kNext, 1>; : public BitField<RequiresBrandCheckFlag, MaybeAssignedFlagField::kNext,
using ParameterNumberField = 1> {};
BitField<uint32_t, RequiresBrandCheckField::kNext, 16>; class ParameterNumberField
: 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,8 +227,9 @@ class ObjectTemplateInfo : public TemplateInfo { ...@@ -227,8 +227,9 @@ class ObjectTemplateInfo : public TemplateInfo {
inline ObjectTemplateInfo GetParent(Isolate* isolate); inline ObjectTemplateInfo GetParent(Isolate* isolate);
private: private:
using IsImmutablePrototype = BitField<bool, 0, 1>; class IsImmutablePrototype : public BitField<bool, 0, 1> {};
using EmbedderFieldCount = BitField<int, IsImmutablePrototype::kNext, 29>; class EmbedderFieldCount
: public BitField<int, IsImmutablePrototype::kNext, 29> {};
OBJECT_CONSTRUCTORS(ObjectTemplateInfo, TemplateInfo); OBJECT_CONSTRUCTORS(ObjectTemplateInfo, TemplateInfo);
}; };
......
...@@ -21,21 +21,22 @@ namespace internal { ...@@ -21,21 +21,22 @@ namespace internal {
namespace { namespace {
using ScopeCallsSloppyEvalField = BitField8<bool, 0, 1>; class ScopeCallsSloppyEvalField : public BitField8<bool, 0, 1> {};
using InnerScopeCallsEvalField = class InnerScopeCallsEvalField
BitField8<bool, ScopeCallsSloppyEvalField::kNext, 1>; : public BitField8<bool, ScopeCallsSloppyEvalField::kNext, 1> {};
using VariableMaybeAssignedField = BitField8<bool, 0, 1>; class VariableMaybeAssignedField : public BitField8<bool, 0, 1> {};
using VariableContextAllocatedField = class VariableContextAllocatedField
BitField8<bool, VariableMaybeAssignedField::kNext, 1>; : public BitField8<bool, VariableMaybeAssignedField::kNext, 1> {};
using HasDataField = BitField<bool, 0, 1>; class HasDataField : public BitField<bool, 0, 1> {};
using LengthEqualsParametersField = BitField<bool, HasDataField::kNext, 1>; class LengthEqualsParametersField
using NumberOfParametersField = : public BitField<bool, HasDataField::kNext, 1> {};
BitField<uint16_t, LengthEqualsParametersField::kNext, 16>; class NumberOfParametersField
: public BitField<uint16_t, LengthEqualsParametersField::kNext, 16> {};
using LanguageField = BitField8<LanguageMode, 0, 1>;
using UsesSuperField = BitField8<bool, LanguageField::kNext, 1>; class LanguageField : public BitField8<LanguageMode, 0, 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];
} }
using IsKeywordBits = BitField8<bool, 0, 1>; class IsKeywordBits : public BitField8<bool, 0, 1> {};
using IsPropertyNameBits = BitField8<bool, IsKeywordBits::kNext, 1>; class IsPropertyNameBits : public 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_); }
using TypeField = BitField<Type, 0, 3>; class TypeField : public BitField<Type, 0, 3> {};
using FromIndexField = BitField<int, 3, 29>; class FromIndexField : public 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.
using AllocateDoubleAlignFlag = BitField<bool, 0, 1>; class AllocateDoubleAlignFlag : public BitField<bool, 0, 1> {};
using AllowLargeObjectAllocationFlag = BitField<bool, 1, 1>; class AllowLargeObjectAllocationFlag : public BitField<bool, 1, 1> {};
using DeclareGlobalsEvalFlag = BitField<bool, 0, 1>; class DeclareGlobalsEvalFlag : public 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,11 +154,12 @@ class SerializerReference { ...@@ -154,11 +154,12 @@ class SerializerReference {
} }
private: private:
using SpaceBits = BitField<SnapshotSpace, 0, kSpaceTagSize>; class SpaceBits : public BitField<SnapshotSpace, 0, kSpaceTagSize> {};
using ChunkIndexBits = class ChunkIndexBits
BitField<uint32_t, SpaceBits::kNext, 32 - kSpaceTagSize>; : public BitField<uint32_t, SpaceBits::kNext, 32 - kSpaceTagSize> {};
using SpecialValueTypeBits = class SpecialValueTypeBits
BitField<SpecialValueType, SpaceBits::kNext, 32 - kSpaceTagSize>; : public BitField<SpecialValueType, SpaceBits::kNext,
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:
using Index = BitField<uint32_t, 0, 31>; class Index : public BitField<uint32_t, 0, 31> {};
using IsFromAPI = BitField<bool, 31, 1>; class IsFromAPI : public 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); }
using ChunkSizeBits = BitField<uint32_t, 0, 31>; class ChunkSizeBits : public BitField<uint32_t, 0, 31> {};
using IsLastChunkBits = BitField<bool, 31, 1>; class IsLastChunkBits : public 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 =
......
...@@ -302,12 +302,9 @@ T SaturateSub(T a, T b) { ...@@ -302,12 +302,9 @@ 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 final { class BitField {
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.
using RequiredBaselineTierField = BitField8<ExecutionTier, 0, 2>; class RequiredBaselineTierField : public BitField8<ExecutionTier, 0, 2> {};
using RequiredTopTierField = BitField8<ExecutionTier, 2, 2>; class RequiredTopTierField : public BitField8<ExecutionTier, 2, 2> {};
using ReachedTierField = BitField8<ExecutionTier, 4, 2>; class ReachedTierField : public 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());
using TestBitField = BitField<unsigned, 3, 3>; class TestBitField : public 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,10 +312,11 @@ TEST(ExponentNumberStr) { ...@@ -312,10 +312,11 @@ 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>;
using OneBit2 = BitField<uint32_t, 7, 1>; class OneBit1: public BitField<uint32_t, 0, 1> {};
using EightBit1 = BitField<uint32_t, 0, 8>; class OneBit2: public BitField<uint32_t, 7, 1> {};
using EightBit2 = BitField<uint32_t, 13, 8>; class EightBit1: public BitField<uint32_t, 0, 8> {};
class EightBit2: public BitField<uint32_t, 13, 8> {};
TEST(BitField) { TEST(BitField) {
uint32_t x; uint32_t x;
...@@ -350,8 +351,9 @@ TEST(BitField) { ...@@ -350,8 +351,9 @@ TEST(BitField) {
CHECK(!EightBit2::is_valid(256)); CHECK(!EightBit2::is_valid(256));
} }
using UpperBits = BitField64<int, 61, 3>;
using MiddleBits = BitField64<int, 31, 2>; class UpperBits: public BitField64<int, 61, 3> {};
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