This is the mail archive of the
mailing list for the GCC project.
Re: [C++ PATCH]: Covariant returns
Gabriel Dos Reis wrote:
I seem to recall that Mark implemented the case where the generic
thunk fails for virtual member functions recently. How would his idea
would be difficult for covariant returns? (I'm just curious).
it wouldn't help. covariant thunks are harder than this-adjusting thunks.
The covariant thunk must adjust the *result* value, and therefore either
a) call the base function, adjust, and then return
b) clone the base function, insert appropriate adjusting code at the
c) use multiple entry points and a 'hidden' parameter, which the base
function uses to adjust the return value.
d) something cleverer
(a) requires a copy of the incoming args to call the thunkee
(b) is similar to the ctor/dtor cloning
(c) is the most space & time efficient mechanism.
(d) is cleverer than me, so I don't know what it is :)
If you need to ask why, ask yourself 'how is the
covariant thunk otherwise going to save a return address without disturbing
the stack frame, caller save or callee save registers?' And yes, both Mark
and I fell into this hole the first time round. (c) could usurp a caller
save for the hidden parm, for instance
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
email@example.com : http://www.cs.bris.ac.uk/~nathan/ : firstname.lastname@example.org