On Friday, 17 August 2012 at 12:36:57 UTC, R Grocott wrote:
Paulo -

Surely there are ways to work around the OS's native ABI, though, even from within compiled code?

Rewriting object vtables (etc.) might be a bit more involved than simple name mangling, but I'm almost certain it would be possible to implement it as part of druntime. The blog post which I linked describes one way to go about it.

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 possible to modify the vtable at runtime. Just access through .__vtable in ClassInfo (I think) and treat it like a regular array. Don't know if that's what you mean.

--
/Jacob Carlborg

Reply via email to