Commits

Slava Pestov committed e0451c8f703
IRGen: Redo concrete subclasses of generic classes Now, such classes will emit a metadata pattern and use the generic metadata instantiation logic. This was all wired up to handle the case of no generic parameters previously, to support resilient struct layout in the runtime. The swift_initializeSuperclass() entry point still exists, providing a fast path for when there's no field layout to do, which is currently always true if we have a concrete class. This entry point no longer needs the global lock, since now we get a per-class lock from the metadata cache. Also, previously we would call the superclass accessor function on every access of class metadata for a concrete subclass of a generic class. Now that we re-use the existing metadata cache logic, this extra call only occurs during initialization. Both swift_initializeSuperclass() and swift_initClassMetadata_UniversalStrategy() used to take the superclass as a parameter, but this isn't really necessary, since it was loaded out of the class metadata immediately prior to the call by the caller. Removing this parameter makes the ABI a little simpler. Once class layout supports resilient types, we will also use swift_initClassMetadata_UniversalStrategy() to lay out classes with resilient types as fields. Singleton metadata caches will still allocate a copy of the template, which is a slight performance regression from the previous implementation of concrete subclasses of generic classes. This will be optimized soon. Right now, the template can always be modified in place; in the future, it will be possible to modify in place as long as the superclass is fixed-layout; a resilient superclass might add or remove fields, thus we cannot leave room for it in the metadata of the subclass, and will need to grow the metadata and slide field offsets at runtime using a new entry point. Also, the representation of the cache itself could be optimized to handle the singleton case, since all we really need here is a lock without any kind of mapping table.