Date: Tue, 9 Dec 2025 16:12:45 +0000
On Tue, Dec 9, 2025 at 12:17 AM Thiago wrote:
>
> There are 6 available registers on the SysV ABI, but only 4 on Windows.
> Moreover, trivially copyable structures are limited to 16 bytes (2 registers)
> on SysV ABI and zero on Windows.
If chimeric_ptr has a constructor that populates a tuple full of
pointers to interfaces, then all the CPU cycles are expended upon the
construction of the chimeric_ptr. Then we have a chimeric_ptr whose
size is = (interfaces_count * sizeof(void*)). From that point forward,
there is minimal CPU work in resolving a member.
However we can reduce the size of a chimeric_ptr to two pointers if we
give it only two member variables:
(1) a 'void*' which points to the original object supplied to the
constructor
(2) a pointer to a function which which converts from T* to Interface*
I've coded this in the following GodBolt:
https://godbolt.org/z/496TTzeqh
On Line #299 - 300, we have the two member variables (i.e. two pointers)
On Line #428, the two pointers are set in the constructor
The GodBolt above is rushed and is missing modifications to 'noexcept'
specifications and so forth, but you can see that it works.
Having just two pointers means that the heavy CPU work is done upon
member resolution instead of upon construction.
>
> There are 6 available registers on the SysV ABI, but only 4 on Windows.
> Moreover, trivially copyable structures are limited to 16 bytes (2 registers)
> on SysV ABI and zero on Windows.
If chimeric_ptr has a constructor that populates a tuple full of
pointers to interfaces, then all the CPU cycles are expended upon the
construction of the chimeric_ptr. Then we have a chimeric_ptr whose
size is = (interfaces_count * sizeof(void*)). From that point forward,
there is minimal CPU work in resolving a member.
However we can reduce the size of a chimeric_ptr to two pointers if we
give it only two member variables:
(1) a 'void*' which points to the original object supplied to the
constructor
(2) a pointer to a function which which converts from T* to Interface*
I've coded this in the following GodBolt:
https://godbolt.org/z/496TTzeqh
On Line #299 - 300, we have the two member variables (i.e. two pointers)
On Line #428, the two pointers are set in the constructor
The GodBolt above is rushed and is missing modifications to 'noexcept'
specifications and so forth, but you can see that it works.
Having just two pointers means that the heavy CPU work is done upon
member resolution instead of upon construction.
Received on 2025-12-09 16:12:58
