On 2012-08-17 12:36:56 +0000, "R Grocott" <[email protected]> said:
Michael -
As far as I can tell, most of the performance cost in your idea comes
from the additional level of indirection, since you store vtable
offsets in a global variable which must be read before each function
call.
This might just be wishful thinking, but would it be possible for
druntime to write new vtable offsets directly into the program's
machine code, at dynamic-link time? That would remove all of the
run-time performance overhead, but, as I say, I'm not sure whether it's
actually possible.
I think the biggest obstacle is that it would require the .text section
(or equivalent) of the executable to be writable. I know that's
possible on Linux, but I'm not sure whether the same is true for most
other operating systems. I guess it might also be a security risk?
It's certainly doable if you put it at the right place. But druntime is
not the one in charge of dynamic linking: the dynamic linker from the
OS is, so that's the ideal place to do such a thing. If you want to do
it in druntime it'll be a huge hassle, if doable at all it'll probably
break easily. But on the OS side you hit a rock because of different
approach to dynamic linking (Windows does not really have a dynamic
linker).
--
Michel Fortin
[email protected]
http://michelf.ca/