[Mono-devel-list] Trampolines...

Willibald Krenn Willibald.Krenn at gmx.at
Mon Feb 21 15:26:20 EST 2005


Hi guys!

I'm a little bit lost on trampolines (esp AMD64): Currently, if a method 
is compiled the first time within the magic service routine (I'll refer 
to this trampoline 'servic routine' for better separation from the 
others) it is checked if the caller can be patched to directly jump to 
the new code. At the same time, the stub (I'll refer to the 'first' 
trampoline 'stub', because it just emits a call to the real trampoline 
which then calls the C-service routine) is patched not to call into the 
trampoline anymore, but to directly call the newly emitted method. 
(While I can see the benefits of doing this, it also means leaving any 
further possibilities of avoiding the stub-jump by inlining the new 
method's address in other callers unused..)

Is this subject to change?
The reason I'm asking is for stub-reference counting: Upon 
recompilation, the method is changed to a stub that calls a new 
trampoline and ends in a new service routine which will look up the 
recompiled code position and patch the callers accordingly. Thereby 
decreasing some refcount in the stub. Goal is to free the space used by 
the first-time compilation of a method (where the stub is located after 
recompilation)..

If the magic service routine won't be changed, it means that all 
callers, except one will go through the stub - meaning that a newly 
compiled method has at maximum 2 different callers (one is the stub, one 
is the patched call). If the service routine will be changed, this 
assumtion does not hold anymore..

BTW: Recompiling/Patching of virtual and non-virtual methods is working 
here - just the refcount part does not work as it should... But I'll 
change that :-)

Be warned: If this is fixed, I'll clean up the code and post it for 
comments here.

Thanks,
  Willi




More information about the Mono-devel-list mailing list