Enhancement of finalizeObject

Godmar Back gback at cs.utah.edu
Tue Dec 8 21:39:46 PST 1998


 Actually, if you wanted to make it even faster, look at the bytecode of 
the finalize method.  If it's an empty function, don't bother invoking it.
Can you implement that?

	- Godmar

> 
> The finalizeObject function lookups a final method every time. 
> It has much overhead in GC, especially with JIT mode.
> Following codes make two times faster!!
> 
> Jongwon Kim
> 
> ------------------------------------------------------------------------------------
> 
> -- classMethod.h --
> ..
> struct Hjava_lang_Class {
>  Hjava_lang_Object head;  /* A class is an object too */
> ..
>  Hjava_lang_ClassLoader* loader;
>  char   state;
>  char   final;
> #ifdef FREEFISH_FIX
>  Method*   finalMethod; /* pointer for final Method */
> #endif
> };
> 
> #ifdef FREEFISH_FIX
> #define CLASS_FINAL_METHOD(CLASS) ((CLASS)->finalMethod)
> #endif
> 
> --- gc-incremental.c ---
> 
> static
> void
> finalizeObject(void* ob)
> {
>  Method* final;
> #ifndef FREEFISH_FIX
>  final = findMethod(OBJECT_CLASS((Hjava_lang_Object*)ob), final_name, void_signature);
> #else
>  Hjava_lang_Class* class = OBJECT_CLASS((Hjava_lang_Object*)ob);
> 
>  if ((final = CLASS_FINAL_METHOD(class)) == 0) {
>   final = findMethod(OBJECT_CLASS((Hjava_lang_Object*)ob), final_name, void_signature);
>   CLASS_FINAL_METHOD(class) = final;
>  } 
> #endif
>  callMethodA(final, METHOD_INDIRECTMETHOD(final), (Hjava_lang_Object*)ob, 0, 0);
>  /* 
>   * make sure thread objects get detached 
>   */
>  if (soft_instanceof(ThreadClass, ob)) {
>   finalizeThread((Hjava_lang_Thread*)ob);
>  }
> }
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~
>     Kim, jongwon
> 
>     freefish at chollian.net
>     freefish at netsgo.com
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~
> 



More information about the kaffe mailing list