@@ -2970,12 +2970,60 @@ TargetContextDescriptor<Runtime>::getModuleContext() const {
29702970
29712971template <typename Runtime>
29722972struct TargetGenericContextDescriptorHeader {
2973- uint16_t NumParams, NumRequirements, NumKeyArguments, NumExtraArguments;
2973+ // / The number of (source-written) generic parameters, and thus
2974+ // / the number of GenericParamDescriptors associated with this
2975+ // / context. The parameter descriptors appear in the order in
2976+ // / which they were given in the source.
2977+ // /
2978+ // / A GenericParamDescriptor corresponds to a type metadata pointer
2979+ // / in the arguments layout when isKeyArgument() is true.
2980+ // / isKeyArgument() will be false if the parameter has been unified
2981+ // / unified with a different parameter or an associated type.
2982+ uint16_t NumParams;
2983+
2984+ // / The number of GenericRequirementDescriptors in this generic
2985+ // / signature.
2986+ // /
2987+ // / A GenericRequirementDescriptor of kind Protocol corresponds
2988+ // / to a witness table pointer in the arguments layout when
2989+ // / isKeyArgument() is true. isKeyArgument() will be false if
2990+ // / the protocol is an Objective-C protocol. (Unlike generic
2991+ // / parameters, redundant conformance requirements can simply be
2992+ // / eliminated, and so that case is not impossible.)
2993+ uint16_t NumRequirements;
2994+
2995+ // / The size of the "key" area of the argument layout, in words.
2996+ // / Key arguments include generic parameters and conformance
2997+ // / requirements which are part of the identity of the context.
2998+ // /
2999+ // / The key area of the argument layout considers of a sequence
3000+ // / of type metadata pointers (in the same order as the parameter
3001+ // / descriptors, for those parameters which satisfy hasKeyArgument())
3002+ // / followed by a sequence of witness table pointers (in the same
3003+ // / order as the requirements, for those requirements which satisfy
3004+ // / hasKeyArgument()).
3005+ uint16_t NumKeyArguments;
3006+
3007+ // / In principle, the size of the "extra" area of the argument
3008+ // / layout, in words. The idea was that extra arguments would
3009+ // / include generic parameters and conformances that are not part
3010+ // / of the identity of the context; however, it's unclear why we
3011+ // / would ever want such a thing. As a result, this section is
3012+ // / unused, and this field is always zero. It can be repurposed
3013+ // / as long as it remains zero in code which must be compatible
3014+ // / with existing Swift runtimes.
3015+ uint16_t NumExtraArguments;
29743016
29753017 uint32_t getNumArguments () const {
29763018 return NumKeyArguments + NumExtraArguments;
29773019 }
29783020
3021+ // / Return the total size of the argument layout, in words.
3022+ // / The alignment of the argument layout is the word alignment.
3023+ uint32_t getArgumentLayoutSizeInWords () const {
3024+ return getNumArguments ();
3025+ }
3026+
29793027 bool hasArguments () const {
29803028 return getNumArguments () > 0 ;
29813029 }
0 commit comments