@@ -195,25 +195,45 @@ using Metadata = TargetMetadata<InProcess>;
195
195
// / For performance, functions returning this type should use SWIFT_CC so
196
196
// / that the components are returned as separate values.
197
197
struct MetadataResponse {
198
- // / For metadata access functions, this is the requested metadata.
199
- // /
200
- // / For metadata initialization functions, this is either null,
201
- // / indicating that initialization was successful, or a metadata on
202
- // / which initialization depends for further progress.
198
+ // / The requested metadata.
203
199
const Metadata *Value;
204
200
205
- // / For metadata access functions, this is the current state of the
206
- // / metadata returned. Always use this instead of trying to inspect
207
- // / the metadata directly; an incomplete metadata may be getting
208
- // / initialized concurrently. This can generally be ignored if the
209
- // / metadata request was for abstract metadata or if the request is
210
- // / blocking.
211
- // /
212
- // / For metadata initialization functions, this is the state that the
213
- // / given metadata needs to be in before initialization can continue.
201
+ // / The current state of the metadata returned. Always use this
202
+ // / instead of trying to inspect the metadata directly to see if it
203
+ // / satisfies the request. An incomplete metadata may be getting
204
+ // / initialized concurrently. But this can generally be ignored if
205
+ // / the metadata request was for abstract metadata or if the request
206
+ // / is blocking.
214
207
MetadataState State;
215
208
};
216
- using MetadataDependency = MetadataResponse;
209
+
210
+ // / A dependency on the metadata progress of other type, indicating that
211
+ // / initialization of a metadata cannot progress until another metadata
212
+ // / reaches a particular state.
213
+ // /
214
+ // / For performance, functions returning this type should use SWIFT_CC so
215
+ // / that the components are returned as separate values.
216
+ struct MetadataDependency {
217
+ // / Either null, indicating that initialization was successful, or
218
+ // / a metadata on which initialization depends for further progress.
219
+ const Metadata *Value;
220
+
221
+ // / The state that Metadata needs to be in before initialization
222
+ // / can continue.
223
+ MetadataState Requirement;
224
+
225
+ MetadataDependency () : Value(nullptr ) {}
226
+ MetadataDependency (const Metadata *metadata, MetadataState requirement)
227
+ : Value(metadata), Requirement(requirement) {}
228
+
229
+ explicit operator bool () const { return Value != nullptr ; }
230
+
231
+ bool operator ==(MetadataDependency other) const {
232
+ assert (Value && other.Value );
233
+ return Value == other.Value &&
234
+ Requirement == other.Requirement ;
235
+ }
236
+ };
217
237
218
238
template <typename Runtime> struct TargetProtocolConformanceDescriptor ;
219
239
@@ -1848,6 +1868,10 @@ struct TargetTupleTypeMetadata : public TargetMetadata<Runtime> {
1848
1868
OpaqueValue *findIn (OpaqueValue *tuple) const {
1849
1869
return (OpaqueValue*) (((char *) tuple) + Offset);
1850
1870
}
1871
+
1872
+ const TypeLayout *getTypeLayout () const {
1873
+ return Type->getTypeLayout ();
1874
+ }
1851
1875
};
1852
1876
1853
1877
Element *getElements () {
@@ -3438,6 +3462,8 @@ class TargetTypeContextDescriptor
3438
3462
return getFullGenericContextHeader ();
3439
3463
}
3440
3464
3465
+ llvm::ArrayRef<GenericParamDescriptor> getGenericParams () const ;
3466
+
3441
3467
// / Return the offset of the start of generic arguments in the nominal
3442
3468
// / type's metadata. The returned value is measured in sizeof(void*).
3443
3469
int32_t getGenericArgumentOffset () const ;
@@ -3575,6 +3601,7 @@ class TargetClassDescriptor final
3575
3601
using TrailingGenericContextObjects::getGenericContext;
3576
3602
using TrailingGenericContextObjects::getGenericContextHeader;
3577
3603
using TrailingGenericContextObjects::getFullGenericContextHeader;
3604
+ using TrailingGenericContextObjects::getGenericParams;
3578
3605
using TargetTypeContextDescriptor<Runtime>::getTypeContextDescriptorFlags;
3579
3606
3580
3607
// / The superclass of this class. This pointer can be interpreted
@@ -3791,6 +3818,7 @@ class TargetStructDescriptor final
3791
3818
using TrailingGenericContextObjects::getGenericContext;
3792
3819
using TrailingGenericContextObjects::getGenericContextHeader;
3793
3820
using TrailingGenericContextObjects::getFullGenericContextHeader;
3821
+ using TrailingGenericContextObjects::getGenericParams;
3794
3822
3795
3823
// / The number of stored properties in the struct.
3796
3824
// / If there is a field offset vector, this is its length.
@@ -3833,6 +3861,7 @@ class TargetEnumDescriptor final
3833
3861
using TrailingGenericContextObjects::getGenericContext;
3834
3862
using TrailingGenericContextObjects::getGenericContextHeader;
3835
3863
using TrailingGenericContextObjects::getFullGenericContextHeader;
3864
+ using TrailingGenericContextObjects::getGenericParams;
3836
3865
3837
3866
// / The number of non-empty cases in the enum are in the low 24 bits;
3838
3867
// / the offset of the payload size in the metadata record in words,
@@ -3937,6 +3966,21 @@ TargetTypeContextDescriptor<Runtime>::getFullGenericContextHeader() const {
3937
3966
}
3938
3967
}
3939
3968
3969
+ template <typename Runtime>
3970
+ llvm::ArrayRef<GenericParamDescriptor>
3971
+ TargetTypeContextDescriptor<Runtime>::getGenericParams() const {
3972
+ switch (this ->getKind ()) {
3973
+ case ContextDescriptorKind::Class:
3974
+ return llvm::cast<TargetClassDescriptor<Runtime>>(this )->getGenericParams ();
3975
+ case ContextDescriptorKind::Enum:
3976
+ return llvm::cast<TargetEnumDescriptor<Runtime>>(this )->getGenericParams ();
3977
+ case ContextDescriptorKind::Struct:
3978
+ return llvm::cast<TargetStructDescriptor<Runtime>>(this )->getGenericParams ();
3979
+ default :
3980
+ swift_runtime_unreachable (" Not a type context descriptor." );
3981
+ }
3982
+ }
3983
+
3940
3984
// / \brief Fetch a uniqued metadata object for a generic nominal type.
3941
3985
SWIFT_RUNTIME_EXPORT SWIFT_CC (swift)
3942
3986
MetadataResponse
@@ -4093,21 +4137,24 @@ swift_getForeignTypeMetadata(ForeignTypeMetadata *nonUnique);
4093
4137
// / \param proposedWitnesses - an optional proposed set of value witnesses.
4094
4138
// / This is useful when working with a non-dependent tuple type
4095
4139
// / where the entrypoint is just being used to unique the metadata.
4096
- SWIFT_RUNTIME_EXPORT
4097
- const TupleTypeMetadata *
4098
- swift_getTupleTypeMetadata (TupleTypeFlags flags,
4140
+ SWIFT_RUNTIME_EXPORT SWIFT_CC (swift)
4141
+ MetadataResponse
4142
+ swift_getTupleTypeMetadata(MetadataRequest request,
4143
+ TupleTypeFlags flags,
4099
4144
const Metadata * const *elements,
4100
4145
const char *labels,
4101
4146
const ValueWitnessTable *proposedWitnesses);
4102
4147
4103
- SWIFT_RUNTIME_EXPORT
4104
- const TupleTypeMetadata *
4105
- swift_getTupleTypeMetadata2 (const Metadata *elt0, const Metadata *elt1,
4148
+ SWIFT_RUNTIME_EXPORT SWIFT_CC (swift)
4149
+ MetadataResponse
4150
+ swift_getTupleTypeMetadata2(MetadataRequest request,
4151
+ const Metadata *elt0, const Metadata *elt1,
4106
4152
const char *labels,
4107
4153
const ValueWitnessTable *proposedWitnesses);
4108
- SWIFT_RUNTIME_EXPORT
4109
- const TupleTypeMetadata *
4110
- swift_getTupleTypeMetadata3 (const Metadata *elt0, const Metadata *elt1,
4154
+ SWIFT_RUNTIME_EXPORT SWIFT_CC (swift)
4155
+ MetadataResponse
4156
+ swift_getTupleTypeMetadata3(MetadataRequest request,
4157
+ const Metadata *elt0, const Metadata *elt1,
4111
4158
const Metadata *elt2, const char *labels,
4112
4159
const ValueWitnessTable *proposedWitnesses);
4113
4160
0 commit comments