29
29
30
30
namespace swift {
31
31
32
- struct TypeLayout ;
32
+ template <typename Runtime>
33
+ struct TargetTypeLayout ;
33
34
template <class Runtime > struct TargetEnumValueWitnessTable ;
34
35
template <typename Runtime> struct TargetMetadata ;
35
36
using Metadata = TargetMetadata<InProcess>;
@@ -120,7 +121,7 @@ class TargetValueWitnessTypes {
120
121
// types for the flags enums.
121
122
typedef size_t size;
122
123
typedef size_t stride;
123
- typedef ValueWitnessFlags flags;
124
+ typedef TargetValueWitnessFlags< typename Runtime::StoredSize> flags;
124
125
typedef uint32_t extraInhabitantCount;
125
126
};
126
127
@@ -214,8 +215,8 @@ template <typename Runtime> struct TargetValueWitnessTable {
214
215
const TargetEnumValueWitnessTable<Runtime> *_asEVWT () const ;
215
216
216
217
// / 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);
219
220
}
220
221
221
222
// / Check whether this metadata is complete.
@@ -224,7 +225,7 @@ template <typename Runtime> struct TargetValueWitnessTable {
224
225
// / "Publish" the layout of this type to other threads. All other stores
225
226
// / to the value witness table (including its extended header) should have
226
227
// / happened before this is called.
227
- void publishLayout (const TypeLayout &layout);
228
+ void publishLayout (const TargetTypeLayout<Runtime> &layout);
228
229
};
229
230
230
231
// / A value-witness table with enum entry points.
@@ -275,23 +276,27 @@ TargetValueWitnessTable<Runtime>::_asEVWT() const {
275
276
// / necessary to perform dependent layout of generic value types. It excludes
276
277
// / the value witness functions and includes only the size, alignment,
277
278
// / 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;
283
286
284
287
private:
285
288
void _static_assert_layout ();
286
289
public:
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) {}
293
298
294
- const TypeLayout *getTypeLayout () const { return this ; }
299
+ const TargetTypeLayout *getTypeLayout () const { return this ; }
295
300
296
301
// / The number of extra inhabitants, that is, bit patterns that do not form
297
302
// / valid values of the type, in this type's binary representation.
@@ -303,14 +308,16 @@ struct TypeLayout {
303
308
return extraInhabitantCount != 0 ;
304
309
}
305
310
};
311
+ using TypeLayout = TargetTypeLayout<InProcess>;
306
312
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" )
314
321
CHECK_TYPE_LAYOUT_OFFSET (size);
315
322
CHECK_TYPE_LAYOUT_OFFSET (flags);
316
323
CHECK_TYPE_LAYOUT_OFFSET (extraInhabitantCount);
0 commit comments