Skip to content

Commit c56879d

Browse files
committed
[ABI] Update ABI documentation to match existential metadata layout.
1 parent a777c5c commit c56879d

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

docs/ABI/TypeMetadata.rst

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,27 +159,32 @@ contain the following fields:
159159
describe the existential container layout used to represent
160160
values of the type. The word is laid out as follows:
161161

162-
* The **number of witness tables** is stored in the least significant 31 bits.
162+
* The **number of witness tables** is stored in the least significant 24 bits.
163163
Values of the protocol type contain this number of witness table pointers
164164
in their layout.
165+
* The **special protocol kind** is stored in 6 bits starting at
166+
bit 24. Only one special protocol kind is defined: the `Error` protocol has
167+
value 1.
168+
* The **superclass constraint indicator** is stored at bit 30. When set, the
169+
protocol type includes a superclass constraint (described below).
165170
* The **class constraint** is stored at bit 31. This bit is set if the type
166171
is **not** class-constrained, meaning that struct, enum, or class values
167172
can be stored in the type. If not set, then only class values can be stored
168173
in the type, and the type uses a more efficient layout.
169174

170-
Note that the field is pointer-sized, even though only the lowest 32 bits are
171-
currently inhabited on all platforms. These values can be derived from the
172-
`protocol descriptor`_ records, but are pre-calculated for convenience.
173-
174175
- The **number of protocols** that make up the protocol composition is stored at
175-
**offset 2**. For the "any" types ``Any`` or ``Any : class``, this
176+
**offset 2**. For the "any" types ``Any`` or ``AnyObject``, this
176177
is zero. For a single-protocol type ``P``, this is one. For a protocol
177178
composition type ``P & Q & ...``, this is the number of protocols.
178179

179-
- The **protocol descriptor vector** begins at **offset 3**. This is an inline
180-
array of pointers to the `protocol descriptor`_ for every protocol in the
181-
composition, or the single protocol descriptor for a protocol type. For
182-
an "any" type, there is no protocol descriptor vector.
180+
- If the **superclass constraint indicator** is set, type metadata for the
181+
superclass follows at the next offset.
182+
183+
- The **protocol vector** follows. This is an inline array of pointers to
184+
descriptions of each protocol in the composition. Each pointer references
185+
either a Swift `protocol descriptor`_ or an Objective-C `Protocol`; the low
186+
bit will be set to indicate when it references an Objective-C protocol. For an
187+
"any" or "AnyObject" type, there is no protocol descriptor vector.
183188

184189
Metatype Metadata
185190
~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)