On 2012-08-18 14:50:54 +0000, "R Grocott" <[email protected]> said:
Hey Michel, posted this question earlier in the thread, but I think you
might have missed it:
The blog post I linked only talks about rewriting vtables at
dynamic-link-time. Would it be possible to implement something similar
for the sizes of structs and scope-classes, and the relative address of
member variables? dsimcha's post has led me to realize that without
these additional features, the ABI would still be quite fragile.
Long story short: Could your proposal realistically be extended to
support flexible sizeofs and member-variable offsets? I figure that
such a system might as well stabilize the entire class ABI, rather than
just vtables.
I would guess that flexible sizeofs would increase the runtime cost
only very slightly, but flexible member-variables might be more of an
issue. The cost could be minimized by looking up offsets only when
crossing a library boundary (say, when calling a template method on an
extern (D_FlexibleABI) class, or accessing a protected member variable
of same), but would that actually be possible?
Apple's Modern Objective-C runtime has a non-fragile ABI that extends
to member variables which works very well. It could be implemented
pretty much the same way in D. There would a very small runtime
overhead for accessing member variables though: each time you access a
member you need need first to read a runtime-initialized global
variable giving you its offset.
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.
By the way, did you take a look at the benchmarks?
<http://michelf.ca/blog/2009/vtable-benchmarking/>
--
Michel Fortin
[email protected]
http://michelf.ca/