diff options
author | Tom Tromey <tromey@redhat.com> | 2003-08-20 15:30:04 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2003-08-20 15:30:04 +0000 |
commit | 9c6f74cd3f4fa7711ab1eb9e7a176450aa699e54 (patch) | |
tree | bc5a1f635f7635aa368beb130e54b30f5f4ec3d5 /libjava | |
parent | 2510de8d0bcb4ced7652762cbdcbe3fd624519e4 (diff) | |
download | gcc-9c6f74cd3f4fa7711ab1eb9e7a176450aa699e54.zip gcc-9c6f74cd3f4fa7711ab1eb9e7a176450aa699e54.tar.gz gcc-9c6f74cd3f4fa7711ab1eb9e7a176450aa699e54.tar.bz2 |
natReference.cc (finalize_referred_to_object): Set `list->reference' to DELETED_REFERENCE when removing dead object.
* java/lang/ref/natReference.cc (finalize_referred_to_object):
Set `list->reference' to DELETED_REFERENCE when removing dead
object.
(find_slot): Added an assert.
(DELETED_REFERENCE): New define.
(add_to_hash): Check for DELETED_REFERENCE.
(remove_from_hash): Just return if found slot isn't ours.
From-SVN: r70599
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 10 | ||||
-rw-r--r-- | libjava/java/lang/ref/natReference.cc | 17 |
2 files changed, 24 insertions, 3 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 57f68fe..c310fb8 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,13 @@ +2003-08-20 Tom Tromey <tromey@redhat.com> + + * java/lang/ref/natReference.cc (finalize_referred_to_object): + Set `list->reference' to DELETED_REFERENCE when removing dead + object. + (find_slot): Added an assert. + (DELETED_REFERENCE): New define. + (add_to_hash): Check for DELETED_REFERENCE. + (remove_from_hash): Just return if found slot isn't ours. + 2003-08-19 Andrew Haley <aph@redhat.com> * prims.cc (unblock_signal): New function. diff --git a/libjava/java/lang/ref/natReference.cc b/libjava/java/lang/ref/natReference.cc index 64262f9..a1550f6 100644 --- a/libjava/java/lang/ref/natReference.cc +++ b/libjava/java/lang/ref/natReference.cc @@ -1,6 +1,6 @@ // natReference.cc - Native code for References -/* Copyright (C) 2001, 2002 Free Software Foundation +/* Copyright (C) 2001, 2002, 2003 Free Software Foundation This file is part of libgcj. @@ -67,6 +67,8 @@ static int hash_count = 0; // Number of slots total in HASH. Must be power of 2. static int hash_size = 0; +#define DELETED_REFERENCE ((jobject) -1) + static object_list * find_slot (jobject key) { @@ -89,7 +91,10 @@ find_slot (jobject key) return &hash[deleted_index]; } else if (ptr->weight == DELETED) - deleted_index = index; + { + deleted_index = index; + JvAssert (ptr->reference == DELETED_REFERENCE); + } index = (index + step) & (hash_size - 1); JvAssert (index != start_index); } @@ -132,6 +137,11 @@ remove_from_hash (jobject obj) java::lang::ref::Reference *ref = reinterpret_cast<java::lang::ref::Reference *> (obj); object_list *head = find_slot (ref->copy); + + // We might have found a new slot. We can just ignore that here. + if (head->reference != ref->copy) + return; + object_list **link = &head->next; head = head->next; @@ -168,7 +178,7 @@ add_to_hash (java::lang::ref::Reference *the_reference) // Use `copy' here because the `referent' field has been cleared. jobject referent = the_reference->copy; object_list *item = find_slot (referent); - if (item->reference == NULL) + if (item->reference == NULL || item->reference == DELETED_REFERENCE) { // New item, so make an entry for the finalizer. item->reference = referent; @@ -217,6 +227,7 @@ finalize_referred_to_object (jobject obj) // run, all the object's references have been processed, and the // object is unreachable. There is, at long last, no way to // resurrect it. + list->reference = DELETED_REFERENCE; list->weight = DELETED; --hash_count; return; |