[swift-dev] [discussion notes] SIL address types and borrowing

Andrew Trick atrick at apple.com
Sat Oct 8 13:36:07 CDT 2016


> On Oct 8, 2016, at 12:39 AM, John McCall <rjmccall at apple.com> wrote:
> 
>> %a = alloc_stack
>> 
>> begin_exclusive %a
>> apply foo(%a) // must be marked an initializer?
>> end_exclusive %a
>> 
>> begin_shared %a
>> apply bar(%a) // immutable access
>> end_shared %a
>> 
>> dealloc_stack %a
> 
> I think alloc_stack returns an owned (but uninitialized) address and there's
> general scoped operation to turn an owned address into a borrow.  Or it could
> be implicit in the operation that needs a borrowed value, as you suggest below.

I should have decorated the code with transitions to get the point across:

%a = alloc_stack   // -> owned/uninitialized

begin_exclusive %a // -> exclusive/uninitialized
apply foo(%a)      // -> exclusive/initialized
end_exclusive %a   // -> owned/initialized

begin_shared %a    // -> shared (implies initialized)
apply bar(%a)      // immutable access
end_shared %a      // -> owned/initialized

dealloc_stack %a   // -> invalid

-Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20161008/4ccd6ba0/attachment.html>


More information about the swift-dev mailing list