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

@@ -7100,12 +7100,12 @@ detail::function_deserializer::deserialize(ModuleFile &MF,
TypeID typeID;
bool isVariadic, isAutoClosure, isNonEphemeral, isIsolated,
isCompileTimeConst;
bool isNoDerivative, isSending;
bool isNoDerivative, isSending, isAddressable;
unsigned rawOwnership;
decls_block::FunctionParamLayout::readRecord(
scratch, labelID, internalLabelID, typeID, isVariadic, isAutoClosure,
isNonEphemeral, rawOwnership, isIsolated, isNoDerivative,
isCompileTimeConst, isSending);
isCompileTimeConst, isSending, isAddressable);
auto ownership = getActualParamDeclSpecifier(
(serialization::ParamDeclSpecifier)rawOwnership);
@@ -7120,7 +7120,8 @@ detail::function_deserializer::deserialize(ModuleFile &MF,
ParameterTypeFlags(isVariadic, isAutoClosure,
isNonEphemeral, *ownership,
isIsolated, isNoDerivative,
isCompileTimeConst, isSending),
isCompileTimeConst, isSending,
isAddressable),
MF.getIdentifier(internalLabelID));
}