Commits

Slava Pestov committed 5d99dc9bb8b
Strawman @fixed_layout attribute and -{enable,disable}-resilience flags A fixed layout type is one about which the compiler is allowed to make certain assumptions across resilience domains. The assumptions will be documented elsewhere, but for the purposes of this patch series, they will include: - the size of the type - offsets of stored properties - whether accessed properties are stored or computed When -enable-resilience is passed to the frontend, all types become resilient unless annotated with the @fixed_layout attribute. So far, the @fixed_layout attribute only comes into play in SIL type lowering of structs and enums, which now become address-only unless they are @fixed_layout. For now, @fixed_layout is also allowed on classes, but has no effect. In the future, support for less resilient type lowering within a single resilience domain will be added, with appropriate loads and stores in function prologs and epilogs. Resilience is not enabled by default, which gives all types fixed layout and matches the behavior of the compiler today. Since we do not want the -enable-resilience flag to change the behavior of existing compiled modules, only the currently-compiling module, Sema adds the @fixed_layout flag to all declarations when the flag is off. To reduce the size of .swiftmodule files, this could become a flag on the module itself in the future. The reasoning behind this is that the usual case is building applications and private frameworks, where there is no need to make anything resilient. For the standard library, we can start out with resilience disabled, while perfoming an audit adding @fixed_layout annotations in the right places. Once the implementation is robust enough we can then build the standard library with resilience enabled.