#if defined(ENABLE_GC_BOEHM)
/* register new finalizer to clean up the lock record */
- GC_REGISTER_FINALIZER(o, lock_record_finalizer, 0, 0, 0);
+ GC_REGISTER_FINALIZER(LLNI_DIRECT(o), lock_record_finalizer, 0, 0, 0);
#endif
/* enter it in the hashtable */
/* lock_hashtable_remove *******************************************************
- Remove the lock record for the given object from the hashtable.
+ Remove the lock record for the given object from the hashtable
+ and free it afterwards.
IN:
+ t....the current thread
o....the object to look up
*******************************************************************************/
-static void lock_hashtable_remove(java_object_t *o)
+static void lock_hashtable_remove(threadobject *t, java_handle_t *o)
{
uintptr_t lockword;
lock_record_t *lr;
/* get lock record */
- lockword = o->lockword;
+ lockword = lock_lockword_get(t, o);
assert(IS_FAT_LOCK(lockword));
/* remove the lock-record from the hashtable */
- slot = heap_hashcode(o) % lock_hashtable.size;
+ LLNI_CRITICAL_START_THREAD(t);
+ slot = heap_hashcode(LLNI_DIRECT(o)) % lock_hashtable.size;
tmplr = lock_hashtable.ptr[slot];
+ LLNI_CRITICAL_END_THREAD(t);
if (tmplr == lr) {
/* special handling if it's the first in the chain */
/* unlock the hashtable */
pthread_mutex_unlock(&(lock_hashtable.mutex));
+
+ /* free the lock record */
+
+ lock_record_free(lr);
}
static void lock_record_finalizer(void *object, void *p)
{
- java_object_t *o;
- uintptr_t lockword;
- lock_record_t *lr;
-
- o = (java_object_t *) object;
-
- /* check for a finalizer function */
+ java_handle_t *o;
+ classinfo *c;
- if (o->vftbl->class->finalizer != NULL)
- finalizer_run(object, p);
+ o = (java_handle_t *) object;
- /* remove the lock-record entry from the hashtable */
+#if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES)
+ /* XXX this is only a dirty hack to make Boehm work with handles */
- lock_hashtable_remove(o);
+ o = LLNI_WRAP((java_object_t *) o);
+#endif
- /* get lock record */
+ LLNI_class_get(o, c);
- lockword = o->lockword;
+#if !defined(NDEBUG)
+ if (opt_DebugFinalizer) {
+ log_start();
+ log_print("[finalizer lockrecord: o=%p p=%p class=", object, p);
+ class_print(c);
+ log_print("]");
+ log_finish();
+ }
+#endif
- assert(IS_FAT_LOCK(lockword));
+ /* check for a finalizer function */
- lr = GET_FAT_LOCK(lockword);
+ if (c->finalizer != NULL)
+ finalizer_run(object, p);
- /* now release the lock record */
+ /* remove the lock-record entry from the hashtable and free it */
- lock_record_free(lr);
+ lock_hashtable_remove(THREADOBJECT, o);
}