@@ -686,6 +686,16 @@ generic constraints:
686
686
* Class protocol types
687
687
* Archetypes constrained by a class protocol
688
688
689
+ Values of loadable types are loaded and stored by loading and storing
690
+ individual components of their representation. As a consequence:
691
+
692
+ * values of loadable types can be loaded into SIL SSA values and stored
693
+ from SSA values into memory without running any user-written code,
694
+ although compiler-generated reference counting operations can happen.
695
+
696
+ * values of loadable types can be take-initialized (moved between
697
+ memory locations) with a bitwise copy.
698
+
689
699
A *loadable aggregate type * is a tuple or struct type that is loadable.
690
700
691
701
A *trivial type * is a loadable type with trivial value semantics.
@@ -706,6 +716,25 @@ generic constraints:
706
716
* Runtime-sized types
707
717
* Non-class protocol types
708
718
* @weak types
719
+ * Types that can't satisfy the requirements for being loadable because they
720
+ care about the exact location of their value in memory and need to run some
721
+ user-written code when they are copied or moved. Most commonly, types "care"
722
+ about the addresses of values because addresses of values are registered in
723
+ some global data structure, or because values may contain pointers into
724
+ themselves. For example:
725
+
726
+ * Addresses of values of Swift ``@weak `` types are registered in a global
727
+ table. That table needs to be adjusted when a ``@weak `` value is copied
728
+ or moved to a new address.
729
+
730
+ * A non-COW collection type with a heap allocation (like ``std::vector `` in
731
+ C++) needs to allocate memory and copy the collection elements when the
732
+ collection is copied.
733
+
734
+ * A non-COW string type that implements a small string optimization (like
735
+ many implementations of ``std::string `` in C++) can contain a pointer
736
+ into the value itself. That pointer needs to be recomputed when the
737
+ string is copied or moved.
709
738
710
739
Values of address-only type ("address-only values") must reside in
711
740
memory and can only be referenced in SIL by address. Addresses of
0 commit comments