What would be the consequence of implementing interfaces as fat pointers ?

Walter Bright newshound2 at digitalmars.com
Sat Mar 29 20:39:11 PDT 2014


On 3/29/2014 8:06 PM, deadalnix wrote:
> On Sunday, 30 March 2014 at 01:42:24 UTC, Walter Bright wrote:
>> True, but why is this a problem?
> Higher memory consumption, less objects fitting in cache, more scanning to do
> for the GC.

Debatable. All fields that are interface references would double in size.


>>> and you don't need cascaded load to call methods.
>>
>> True, but on the other hand, it takes up 2 registers rather than one, costing
>> twice as much to copy around, store, pass/return to functions, etc.
>
> Two pointers structs are passed in register, which is fast. If that spill, that
> spill on stack, which is hot, and prefetcher friendly.

That underestimates how precious register real estate is on the x86.


> On the other hand, the double indirection is very cache unfriendly.

I suspect that the results of all this will be some use cases go faster, other 
use cases go slower, a decidedly mixed result.



More information about the Digitalmars-d mailing list