Fragile ABI

R Grocott rgrocottbugzilla at gmail.com
Sat Aug 18 12:36:41 PDT 2012


On Saturday, 18 August 2012 at 17:55:22 UTC, Michel Fortin wrote:
> As for structs, you could do it the same way, but I don't think 
> you'd get enough benefit to compensate the drawback in 
> performance and elsewhere. To truly have non-fragile structs 
> you'd need to disable almost all compile-time introspection 
> too. That would be very disruptive.
>
> So I don't think it makes sense to have non-fragile structs.

Can't D allocate classes on the stack, in some circumstances? 
Would this lead to the same problems that you just described, or 
is the problem caused by how structs and classes are used, rather 
than how they're implemented?

> By the way, did you take a look at the benchmarks?
> <http://michelf.ca/blog/2009/vtable-benchmarking/>

Those are some pretty interesting numbers - seems as though the 
overhead is only about 10% - 20% over that of a regular vtable 
dispatch? I would have guessed that it would almost double the 
overhead, but I suppose that most of the overhead of a function 
call comes from saving registers, managing the stack, etc.

The overhead is so small, in fact, that I'd feel quite 
comfortable using it in a very performance-sensitive situation 
(like, say, a rasterizer library), presuming that your benchmarks 
were accurate. Another strong argument in favour of trying to 
have this system implemented :)


More information about the Digitalmars-d mailing list