mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
DeclContexts as they exist today are "over aligned" when compared to their natural alignment boundary and therefore they can easily cause adjacent padding when dropped into the middle of objects via C++ inheritance, or when the clang importer prefaces Swift AST allocations with a pointer to the corresponding clang AST node. With this change, we move DeclContexts to the front of the memory layout of AST nodes. This allows us to restore natural alignment, save memory, and as a side effect: more easily avoid "over alignment" in the future because DeclContexts now only need to directly track which AST node hierarchy they're associated with, not specific AST nodes within each hierarchy. Finally, as a word of caution, after this change one can no longer assume that AST nodes safely convert back and forth with "void*". For example, WitnessTableEntry needed fixing with this change.
51 KiB
51 KiB