[swift-dev] SIL: "unowned" the calling convention and "unowned" the variable ownership convention

Jordan Rose jordan_rose at apple.com
Mon Jan 4 13:07:22 CST 2016


Hi, Michael. The calling convention is equivalent to the 'unowned(unsafe)' variant of 'unowned', so I don't think it's entirely unrelated.

I don't like "Immediate" because I don't know what it means. Admittedly I don't work on SIL, but when is something passed "immediate" as opposed to "guaranteed"? Is "immediate" the case where it's valid now but mutating any external memory could make it invalid? What makes that "immediate"?

Jordan


> On Dec 29, 2015, at 15:18, Michael Gottesman via swift-dev <swift-dev at swift.org> wrote:
> 
> One form of overloading that we currently have at the SIL level are the notions of the "unowned" calling convention and "unowned" the variable ownership convention.
> 
> For those who are unfamiliar with the unowned calling convention consider the following:
> 
> @tmp : $@convention(thin) (@owned Array<Double>, Array<Double>, Int, Int) -> Array<Double>
> 
> In this case the first parameter is passed in @owned (i.e. +1) and the second parameter is passed in as "unowned". Unowned is a form of +0 parameter passing that essentially means that the callee needs to take ownership of the value (ideally) before performing any side-effect having operations.
> 
> Overloading the term "unowned" in this way is confusing for new people at the SIL level. I would like to propose that we rename the unowned calling convention to something else (since unowned the variable ownership convention corresponds to a swift level concept that will be more difficult to change). Additionally no matter what we do, we should annotate "unowned" parameters and return values with an appropriate @"..." sigil to make it absolutely clear visually what the convention is.
> 
> In terms of names, I am partial to the name "immediate". My reasoning for using the term immediate is related to SGFContext in SILGen. In SILGen, there are three types of desired transfers defined by the DesiredTransfer enum.
> 
>  enum DesiredTransfer {                                                                                                                                                         
>    PlusOne,                                                                                                                                                                     
>    ImmediatePlusZero,                                                                                                                                                           
>    GuaranteedPlusZero,                                                                                                                                                          
>  };
> 
> PlusOne refers to @owned, GuaranteedPlusZero refers to @guaranteed, and if my memory is correct, ImmediatePlusZero refers to unowned. It seems natural to me to choose immediate for the name of the convention to match the terminology in SGFContext.
> 
> Comments, flames, etc?
> 
> Michael
> _______________________________________________
> swift-dev mailing list
> swift-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev



More information about the swift-dev mailing list