need to focus on java performance?
David Daney
ddaney@avtrex.com
Thu May 25 14:55:00 GMT 2006
Andrew Haley wrote:
> Bryce McKinlay writes:
> > Andrew Haley wrote:
> > > Once the class was initialized, you'd need to rewrite the
> > > instructions in the trampolines to point to the static methods
> > > that don't do class initialization. While all this was going on,
> > > there still would be threads jumping to these trampolines.
> > > However, these trampolines are not themseolves protected by
> > > locks, and there's no guarantee that you can rewrite the
> > > instructions atomically. So, you'd run the risk of a partially
> > > rewritten instruction being executed. If you can rewrite the
> > > trampolines atomically then I think you might be OK.
> >
> > Why rewrite the trampolines? Once a class is initialized, its
> > atable entries are updated to point to the real function. Swapping
> > function pointers in the atable is atomic.
>
> Ah, OK, you're fixing up the caller's pointers rather than anything in
> the target. I can see that would work, but there are potentially many
> atable entries in many classes pointing to a static method. Also,
> you'd need a fast way to find the caller.
>
Only patch the caller when it traverses the atable entry. The atable
entries that are never traversed don't matter, so you don't have to
patch them.
The calling method's address is in the standard location (as specified
by the ABI), we know how to find the class given this information. It
would be nice if it were fast, but even if it isn't I think there would
still be better performance, as you only patch each atable entry once.
David Daney
More information about the Java
mailing list