[swift-evolution] Pitch: (Almost) std libs
Félix Cloutier
felixcca at yahoo.ca
Wed Jan 27 00:44:27 CST 2016
Do note that any function that is dynamically linked to your program is reached through an indirect jump. This is probably what David means when he says that it uses dynamic dispatch.
Félix
> Le 26 janv. 2016 à 22:48:49, Trent Nadeau via swift-evolution <swift-evolution at swift.org> a écrit :
>
> Okay. That makes more sense. I was wondering where you would even have dynamic dispatch to a normal function.
>
> On Tue, Jan 26, 2016 at 10:46 PM, Jordan Rose <jordan_rose at apple.com <mailto:jordan_rose at apple.com>> wrote:
>
>> On Jan 26, 2016, at 19:45 , Jordan Rose <jordan_rose at apple.com <mailto:jordan_rose at apple.com>> wrote:
>>
>>
>>> On Jan 26, 2016, at 18:49 , David Turnbull via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>
>>> Functions in a module go through dynamic dispatch. Operators are functions. So multiplying two complex numbers won't get inlined. The stdlib uses internal tricks so what appears as a module you import is available to be specialized and inlined.
>>>
>>> To see this in action, try the CubeWorld demo from here: https://github.com/AE9RB/SwiftGL <https://github.com/AE9RB/SwiftGL>
>>> Then change it so the math libraries aren't modules (move the files, delete the import statements). On my system, CPU drops from 60% to 6%. It's also the difference between 150 cubes and 1200 cubes at 60 fps. Make sure you turn on WMO.
>>>
>>> I'm told it won't always be this way. But it is today.
>>
>> Yep. We're planning to improve this but right now it's true: inlining and generic specialization does not happen across framework boundaries.
>
> Only the generics are really "dynamic dispatch", though. Non-generic code is just "function calls that aren't inlined".
>
> Jordan
>
>
>
>
> --
> Trent Nadeau
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160127/fff6b078/attachment.html>
More information about the swift-evolution
mailing list