[Development] Passing QSize, QPoint, QTime and other small structs by value
giuseppe.dangelo at kdab.com
Fri Apr 7 21:45:49 CEST 2017
Il 07/04/2017 19:54, Thiago Macieira ha scritto:
>> Sorry, what do you mean "is fine"? What's not fine?
> Passing float or double by value means they get passed in the x87 registers.
> Passing float inside a struct means it's passed in the x86 stack instead.
This is a separate discussion, though. I.e. not "by value", not "by
const ref", but "unpacked field by field". Unlike value/const-ref, which
has also implications for the compiler (no aliasing, better value
tracking, etc.), value/unpacked should be purely about optimizing for
And I still wonder: is any of this really an issue on modern
superscalar, out of order CPU architectures? Does anyone know hard
numbers, research papers, tooling, anything to show that unpacking gives
actual benefits, because CPU vendors cannot or did not optimize for this
I've tried to measure the difference of calling f(QStringView) vs.
f(char16_t*, size_t) on Windows, and the results were simply lost in the
variance. (And then whatever results I would've extracted, I'm sure they
would likely be completely different on another CPU).
My 2 c,
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908
KDAB - Qt, C++ and OpenGL Experts
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4007 bytes
Desc: Firma crittografica S/MIME
More information about the Development