Binary compatibility and finding compiled classes

Jakob Praher jpraher@yahoo.de
Mon Oct 11 20:50:00 GMT 2004


Am Mon, den 11.10.2004 schrieb Andrew Haley um 13:55:
> Jakob Praher writes:

> > 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.
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?
If not one could do this, but solely to eliminate the need to lookup in
the otable for the offset, but to hard code the offset into the callers
jump. but its probably too hard, I was sketching an asm version of it
but then I didn't found a clean solution how to get the offset from the
call without changing the caller. And also it perhaps doesn't pay that
every first method is performing worse.
Here you can see, what's my understanding from the otable/atable stuff
from reading the assembler output.
class Foo {
 public String hello( ) { returen "Hello"; }
}
class Bar {
 public static void main( String[] args ) { 
 Foo f = new Foo( );
 String s = f.hello( );
 }
}
// this is just the stuff I've collected from the assembler output
// this is not authorative
typedef jobject PF_JvInitObject( jobject obj );
typedef jobject PF_Method1( jobject obj );
/* fill in the {o,i,a,v}table of the class Bar
 * this does a _Jv_FindClass on all dependent objects
 */
_Jv_InitClass( &Bar::class$ );
/* this is proably Bar::class$.
jclass fooClass = _CD_Bar + 4; 	// Class Descriptor reference table 
// call foo initializer
jobject foo = _Jv_AllocObjectNoFinalizer( fooClass ); 
PF_InitObject initObj = (PF_InitObject)*(_atable_Bar + 4);
initObj( foo );
void * fooVtbl = (*foo);
int helloOffset = _otable_Bar + 4:
PF_Method1 m1 = (PF_Method1)*(fooVtbl + helloOffset);
jobject string = m1( foo );
//...
Jakob


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /