This is the mail archive of the java@gcc.gnu.org mailing list for the Java 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: Binary compatibility and finding compiled classes


Jakob Praher wrote:

> ok. So you mean, like the symbol table the ELF linker uses for linking?

The symbol table in an ELF shared object contains a hash table for
fast lookups. We don't do that with our metadata, but we could.



regarding hasing vs table lookup.


If you would use a hash table, you would put the Method_Symbol stuff and
the offset into the hashtable?


So hashtable
hashCode({ClassName,MethodName,Signature})->offset ?
but thats whats already there now, since the compiler computes a hard
coded offset by which the _Jv_Linker knows which
{ClassName,MethodName,Signature} of {o,a}table_syms is going to be used
for the {o,a}table slot.


Exactly, the code generated by the compiler already knows which otable slot to use. The hashtable would be used to speed up the look-up of methods when the runtime is filling out the tables when linking a class. Currently, to go from a {ClassName,MethodName,Signature} to a _Jv_Method requires linear searching through the class hierarchy. This would speed up method lookups in reflection and JNI, too. Personally, I'm not 100% sure that the gains from hash look-ups will outweigh the cost and extra memory of generating the hash tables, but its definitely something we need to keep an eye on - linking needs to be as efficient as possible.

Perhaps doing inline chaching in static compiled environments is rather
hard. How does PIC C functions get optimized? I mean there are called by
the a stub which looks in the .plt table and then jumps to the effective
address. Does the stub then change the callers address (by using the
return address pushed on the stack) or is the stub called every time?


PLT calls will call the stub every time. This way, only the stub needs to be modified at runtime: the calling code remains read-only and copy-on-write is avoided. For this reason, surprisingly, standard C calls to PIC code can actually be slower than virtual calls that go via the vtable and avoid the PLT.

Regards

Bryce


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