This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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
return point.
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[1]
(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 :)


[1]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   ::   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?' : :

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]