Thursday, July 5, 2018 [Tweets] [Favorites]

Swift 4.2’s New Calling Convention

Jesse Squires:

It is no longer the callee’s responsibility to release the object. So, all of the superfluous retains and releases go away. Ted notes in the talk that this significant reduction in retain and release traffic results in a code size reduction as well as a runtime performance improvement, because all those calls have been removed.

[…]

What’s more interesting with this change is the case of calling non-inlinable functions across module boundaries. Michael Gottesman shared this gist on Twitter to explain. I doubt many people saw that Tweet, so I wanted to highlight it.

The new convention seems more like Objective-C.

Update (2018-07-05): Joe Groff:

Still an important diff between Swift and ObjC—in Swift, the caller guarantees the validity of references, so callee never needs to retain. […]

Swift also still uses the +1 convention by default in situations where it’s most likely to be profitable, such as for the newValue in property setters or the arguments to inits, since these arguments are likely to be stored in the receiving object

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment