2929
3030namespace swift {
3131
32- struct TypeLayout ;
32+ template <typename Runtime>
33+ struct TargetTypeLayout ;
3334template <class Runtime > struct TargetEnumValueWitnessTable ;
3435template <typename Runtime> struct TargetMetadata ;
3536using Metadata = TargetMetadata<InProcess>;
@@ -120,7 +121,7 @@ class TargetValueWitnessTypes {
120121 // types for the flags enums.
121122 typedef size_t size;
122123 typedef size_t stride;
123- typedef ValueWitnessFlags flags;
124+ typedef TargetValueWitnessFlags< typename Runtime::StoredSize> flags;
124125 typedef uint32_t extraInhabitantCount;
125126};
126127
@@ -214,8 +215,8 @@ template <typename Runtime> struct TargetValueWitnessTable {
214215 const TargetEnumValueWitnessTable<Runtime> *_asEVWT () const ;
215216
216217 // / Get the type layout record within this value witness table.
217- const TypeLayout *getTypeLayout () const {
218- return reinterpret_cast <const TypeLayout *>(&size);
218+ const TargetTypeLayout<Runtime> *getTypeLayout () const {
219+ return reinterpret_cast <const TargetTypeLayout<Runtime> *>(&size);
219220 }
220221
221222 // / Check whether this metadata is complete.
@@ -224,7 +225,7 @@ template <typename Runtime> struct TargetValueWitnessTable {
224225 // / "Publish" the layout of this type to other threads. All other stores
225226 // / to the value witness table (including its extended header) should have
226227 // / happened before this is called.
227- void publishLayout (const TypeLayout &layout);
228+ void publishLayout (const TargetTypeLayout<Runtime> &layout);
228229};
229230
230231// / A value-witness table with enum entry points.
@@ -275,23 +276,27 @@ TargetValueWitnessTable<Runtime>::_asEVWT() const {
275276// / necessary to perform dependent layout of generic value types. It excludes
276277// / the value witness functions and includes only the size, alignment,
277278// / extra inhabitants, and miscellaneous flags about the type.
278- struct TypeLayout {
279- ValueWitnessTypes::size size;
280- ValueWitnessTypes::stride stride;
281- ValueWitnessTypes::flags flags;
282- ValueWitnessTypes::extraInhabitantCount extraInhabitantCount;
279+ template <typename Runtime>
280+ struct TargetTypeLayout {
281+ typename TargetValueWitnessTypes<Runtime>::size size;
282+ typename TargetValueWitnessTypes<Runtime>::stride stride;
283+ typename TargetValueWitnessTypes<Runtime>::flags flags;
284+ typename TargetValueWitnessTypes<Runtime>::extraInhabitantCount
285+ extraInhabitantCount;
283286
284287private:
285288 void _static_assert_layout ();
286289public:
287- TypeLayout () = default ;
288- constexpr TypeLayout (ValueWitnessTypes::size size,
289- ValueWitnessTypes::stride stride,
290- ValueWitnessTypes::flags flags,
291- ValueWitnessTypes::extraInhabitantCount xiCount)
292- : size(size), stride(stride), flags(flags), extraInhabitantCount(xiCount) {}
290+ TargetTypeLayout () = default ;
291+ constexpr TargetTypeLayout (
292+ typename TargetValueWitnessTypes<Runtime>::size size,
293+ typename TargetValueWitnessTypes<Runtime>::stride stride,
294+ typename TargetValueWitnessTypes<Runtime>::flags flags,
295+ typename TargetValueWitnessTypes<Runtime>::extraInhabitantCount xiCount)
296+ : size(size), stride(stride), flags(flags),
297+ extraInhabitantCount(xiCount) {}
293298
294- const TypeLayout *getTypeLayout () const { return this ; }
299+ const TargetTypeLayout *getTypeLayout () const { return this ; }
295300
296301 // / The number of extra inhabitants, that is, bit patterns that do not form
297302 // / valid values of the type, in this type's binary representation.
@@ -303,14 +308,16 @@ struct TypeLayout {
303308 return extraInhabitantCount != 0 ;
304309 }
305310};
311+ using TypeLayout = TargetTypeLayout<InProcess>;
306312
307- inline void TypeLayout::_static_assert_layout () {
308- #define CHECK_TYPE_LAYOUT_OFFSET (FIELD ) \
309- static_assert (offsetof (ValueWitnessTable, FIELD) \
310- - offsetof (ValueWitnessTable, size) \
311- == offsetof (TypeLayout, FIELD), \
312- " layout of " #FIELD " in TypeLayout doesn't match " \
313- " value witness table" )
313+ template <typename Runtime>
314+ inline void TargetTypeLayout<Runtime>::_static_assert_layout() {
315+ #define CHECK_TYPE_LAYOUT_OFFSET (FIELD ) \
316+ static_assert (offsetof (TargetValueWitnessTable<Runtime>, FIELD) - \
317+ offsetof (TargetValueWitnessTable<Runtime>, size) == \
318+ offsetof (TargetTypeLayout<Runtime>, FIELD), \
319+ " layout of " #FIELD " in TypeLayout doesn't match " \
320+ " value witness table" )
314321 CHECK_TYPE_LAYOUT_OFFSET (size);
315322 CHECK_TYPE_LAYOUT_OFFSET (flags);
316323 CHECK_TYPE_LAYOUT_OFFSET (extraInhabitantCount);
0 commit comments