[Development] Passing QSize, QPoint, QTime and other small structs by value
Giuseppe D'Angelo
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
the ABI.
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
case?
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...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4007 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20170407/ebe699a9/attachment.bin>
More information about the Development
mailing list