diff --git a/src/objects/debug-objects.h b/src/objects/debug-objects.h index 8604f398a1..f252276914 100644 --- a/src/objects/debug-objects.h +++ b/src/objects/debug-objects.h @@ -24,10 +24,10 @@ class BytecodeArray; // The DebugInfo class holds additional information for a function being // debugged. -class DebugInfo : public TorqueGeneratedDebugInfo, - public TorqueGeneratedDebugInfoFlagsFields { +class DebugInfo : public TorqueGeneratedDebugInfo { public: NEVER_READ_ONLY_SPACE + DEFINE_TORQUE_GENERATED_DEBUG_INFO_FLAGS() using Flags = base::Flags; // A bitfield that lists uses of the current instance. diff --git a/src/objects/map.h b/src/objects/map.h index 58481ae157..ce4ec4721f 100644 --- a/src/objects/map.h +++ b/src/objects/map.h @@ -253,7 +253,9 @@ class Map : public HeapObject { DECL_PRIMITIVE_ACCESSORS(relaxed_bit_field, byte) // Bit positions for |bit_field|. - using Bits1 = TorqueGeneratedMapBitFields1Fields; + struct Bits1 { + DEFINE_TORQUE_GENERATED_MAP_BIT_FIELDS1() + }; // // Bit field 2. @@ -261,7 +263,9 @@ class Map : public HeapObject { DECL_PRIMITIVE_ACCESSORS(bit_field2, byte) // Bit positions for |bit_field2|. - using Bits2 = TorqueGeneratedMapBitFields2Fields; + struct Bits2 { + DEFINE_TORQUE_GENERATED_MAP_BIT_FIELDS2() + }; // // Bit field 3. @@ -273,7 +277,9 @@ class Map : public HeapObject { V8_INLINE void clear_padding(); // Bit positions for |bit_field3|. - using Bits3 = TorqueGeneratedMapBitFields3Fields; + struct Bits3 { + DEFINE_TORQUE_GENERATED_MAP_BIT_FIELDS3() + }; // Ensure that Torque-defined bit widths for |bit_field3| are as expected. STATIC_ASSERT(Bits3::EnumLengthBits::kSize == kDescriptorIndexBitCount); diff --git a/src/objects/name.h b/src/objects/name.h index 783beb12a5..3d3c10446a 100644 --- a/src/objects/name.h +++ b/src/objects/name.h @@ -139,9 +139,10 @@ class Name : public TorqueGeneratedName { }; // ES6 symbols. -class Symbol : public TorqueGeneratedSymbol, - public TorqueGeneratedSymbolFlagsFields { +class Symbol : public TorqueGeneratedSymbol { public: + DEFINE_TORQUE_GENERATED_SYMBOL_FLAGS() + // [is_private]: Whether this is a private symbol. Private symbols can only // be used to designate own properties of objects. DECL_BOOLEAN_ACCESSORS(is_private) diff --git a/src/objects/scope-info.h b/src/objects/scope-info.h index 0f078b2d36..78eba066d0 100644 --- a/src/objects/scope-info.h +++ b/src/objects/scope-info.h @@ -37,8 +37,10 @@ class Zone; // This object provides quick access to scope info details for runtime // routines. -class ScopeInfo : public FixedArray, public TorqueGeneratedScopeFlagsFields { +class ScopeInfo : public FixedArray { public: + DEFINE_TORQUE_GENERATED_SCOPE_FLAGS() + DECL_CAST(ScopeInfo) DECL_PRINTER(ScopeInfo) diff --git a/src/objects/shared-function-info.h b/src/objects/shared-function-info.h index 0a0ed81f3f..a8a5a51f70 100644 --- a/src/objects/shared-function-info.h +++ b/src/objects/shared-function-info.h @@ -167,10 +167,10 @@ class InterpreterData : public Struct { // SharedFunctionInfo describes the JSFunction information that can be // shared by multiple instances of the function. -class SharedFunctionInfo : public HeapObject, - public TorqueGeneratedSharedFunctionInfoFlagsFields { +class SharedFunctionInfo : public HeapObject { public: NEVER_READ_ONLY_SPACE + DEFINE_TORQUE_GENERATED_SHARED_FUNCTION_INFO_FLAGS() // This initializes the SharedFunctionInfo after allocation. It must // initialize all fields, and leave the SharedFunctionInfo in a state where diff --git a/src/torque/csa-generator.cc b/src/torque/csa-generator.cc index acbba7e1c5..da459fd08a 100644 --- a/src/torque/csa-generator.cc +++ b/src/torque/csa-generator.cc @@ -858,9 +858,12 @@ void CSAGenerator::EmitInstruction(const StoreReferenceInstruction& instruction, namespace { std::string GetBitFieldSpecialization(const BitFieldStructType* container, const BitField& field) { - std::string suffix = field.num_bits == 1 ? "Bit" : "Bits"; - return "TorqueGenerated" + container->name() + - "Fields::" + CamelifyString(field.name_and_type.name) + suffix; + std::stringstream stream; + stream << "base::BitField<" + << field.name_and_type.type->GetConstexprGeneratedTypeName() << ", " + << field.offset << ", " << field.num_bits << ", " + << container->GetConstexprGeneratedTypeName() << ">"; + return stream.str(); } } // namespace diff --git a/src/torque/implementation-visitor.cc b/src/torque/implementation-visitor.cc index 123917aba7..916d589765 100644 --- a/src/torque/implementation-visitor.cc +++ b/src/torque/implementation-visitor.cc @@ -3250,20 +3250,11 @@ void ImplementationVisitor::GenerateBitFields( header << "#include \"src/base/bit-field.h\"\n\n"; NamespaceScope namespaces(header, {"v8", "internal"}); - // TODO(v8:7793): Once we can define enums in Torque, we should be able to - // do something nicer than hard-coding these predeclarations. Until then, - // any enum used as a bitfield must be included in this list. - header << R"( -enum class FunctionSyntaxKind : uint8_t; -enum class BailoutReason : uint8_t; -enum FunctionKind : uint8_t; - -)"; - for (const auto& type : TypeOracle::GetBitFieldStructTypes()) { bool all_single_bits = true; // Track whether every field is one bit. - header << "struct TorqueGenerated" << type->name() << "Fields {\n"; + header << "#define DEFINE_TORQUE_GENERATED_" + << CapifyStringWithUnderscores(type->name()) << "() \\\n"; std::string type_name = type->GetConstexprGeneratedTypeName(); for (const auto& field : type->fields()) { const char* suffix = field.num_bits == 1 ? "Bit" : "Bits"; @@ -3273,21 +3264,21 @@ enum FunctionKind : uint8_t; header << " using " << CamelifyString(field.name_and_type.name) << suffix << " = base::BitField<" << field_type_name << ", " << field.offset << ", " << field.num_bits << ", " << type_name - << ">;\n"; + << ">; \\\n"; } // If every field is one bit, we can also generate a convenient enum. if (all_single_bits) { - header << " enum Flag {\n"; - header << " kNone = 0,\n"; + header << " enum Flag { \\\n"; + header << " kNone = 0, \\\n"; for (const auto& field : type->fields()) { header << " k" << CamelifyString(field.name_and_type.name) - << " = 1 << " << field.offset << ",\n"; + << " = 1 << " << field.offset << ", \\\n"; } - header << " };\n"; + header << " }; \\\n"; } - header << "};\n\n"; + header << "\n"; } } const std::string output_header_path = output_directory + "/" + file_name;