Prototype an @_addressable attribute that puts an argument at a stable address.

Many APIs using nonescapable types would like to vend interior pointers to their
parameter bindings, but this isn't normally always possible because of representation
changes the caller may do around the call, such as moving the value in or out of memory,
bridging or reabstracting it, etc. `@_addressable` forces the corresponding parameter
to be passed indirectly in memory, in its maximally-abstracted representation.
[TODO] If return values have a lifetime dependency on this parameter, the caller must
keep this in-memory representation alive for the duration of the dependent value's
lifetime.
This commit is contained in:
Joe Groff
2024-07-16 18:50:31 -07:00
parent ecf7ac910e
commit 3c0b08dbcb
18 changed files with 227 additions and 37 deletions

View File

@@ -58,7 +58,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
/// describe what change you made. The content of this comment isn't important;
/// it just ensures a conflict if two people change the module format.
/// Don't worry about adhering to the 80-column limit for this line.
const uint16_t SWIFTMODULE_VERSION_MINOR = 904; // @available renamed decl ID removed
const uint16_t SWIFTMODULE_VERSION_MINOR = 905; // "addressable" param bit
/// A standard hash seed used for all string hashes in a serialized module.
///
@@ -1312,7 +1312,8 @@ namespace decls_block {
BCFixed<1>, // isolated
BCFixed<1>, // noDerivative?
BCFixed<1>, // compileTimeConst
BCFixed<1> // sending
BCFixed<1>, // sending
BCFixed<1> // addressable
>;
TYPE_LAYOUT(MetatypeTypeLayout,