aboutsummaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2005-05-25 15:23:56 +0000
committerTom Tromey <tromey@gcc.gnu.org>2005-05-25 15:23:56 +0000
commit93f8e21b71a52f12a70eb8556c244ed886612bbd (patch)
tree14b238eff9b75fc8a5c871087ee4eece2bb8e3a9 /libjava
parent56c0cf75a09e159f97a8bd2e5dcc484cc0db9566 (diff)
downloadgcc-93f8e21b71a52f12a70eb8556c244ed886612bbd.zip
gcc-93f8e21b71a52f12a70eb8556c244ed886612bbd.tar.gz
gcc-93f8e21b71a52f12a70eb8556c244ed886612bbd.tar.bz2
re PR libgcj/21703 (hang when rapidly calling String.intern())
PR libgcj/21703: * java/lang/ref/natReference.cc (find_slot): Handle case where table has no NULL entries. * java/lang/natString.cc (_Jv_StringFindSlot): Handle case where table has no NULL entries. From-SVN: r100153
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog8
-rw-r--r--libjava/java/lang/natString.cc10
-rw-r--r--libjava/java/lang/ref/natReference.cc10
3 files changed, 22 insertions, 6 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 236dd4f..4d1cfb9 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,11 @@
+2005-05-21 Tom Tromey <tromey@redhat.com>
+
+ PR libgcj/21703:
+ * java/lang/ref/natReference.cc (find_slot): Handle case where
+ table has no NULL entries.
+ * java/lang/natString.cc (_Jv_StringFindSlot): Handle case where
+ table has no NULL entries.
+
2005-05-22 Andreas Jaeger <aj@suse.de>
* java/lang/mprec.c (mult, lshift, b2d, d2b): Add parenthesis to
diff --git a/libjava/java/lang/natString.cc b/libjava/java/lang/natString.cc
index 6e8febc..a14f5de 100644
--- a/libjava/java/lang/natString.cc
+++ b/libjava/java/lang/natString.cc
@@ -1,6 +1,6 @@
// natString.cc - Implementation of java.lang.String native methods.
-/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation
This file is part of libgcj.
@@ -64,7 +64,7 @@ _Jv_StringFindSlot (jchar* data, jint len, jint hash)
int index = start_index;
/* step must be non-zero, and relatively prime with strhash_size. */
jint step = (hash ^ (hash >> 16)) | 1;
- for (;;)
+ do
{
jstring* ptr = &strhash[index];
jstring value = (jstring) UNMASK_PTR (*ptr);
@@ -81,8 +81,12 @@ _Jv_StringFindSlot (jchar* data, jint len, jint hash)
&& memcmp(JvGetStringChars(value), data, 2*len) == 0)
return (ptr);
index = (index + step) & (strhash_size - 1);
- JvAssert (index != start_index);
}
+ while (index != start_index);
+ // Note that we can have INDEX == START_INDEX if the table has no
+ // NULL entries but does have DELETED_STRING entries.
+ JvAssert (deleted_index >= 0);
+ return &strhash[deleted_index];
}
/* Calculate a hash code for the string starting at PTR at given LENGTH.
diff --git a/libjava/java/lang/ref/natReference.cc b/libjava/java/lang/ref/natReference.cc
index e322ae3..5ad5b10 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, 2003 Free Software Foundation
+/* Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation
This file is part of libgcj.
@@ -78,7 +78,7 @@ find_slot (jobject key)
int start_index = hcode & (hash_size - 1);
int index = start_index;
int deleted_index = -1;
- for (;;)
+ do
{
object_list *ptr = &hash[index];
if (ptr->reference == key)
@@ -96,8 +96,12 @@ find_slot (jobject key)
JvAssert (ptr->reference == DELETED_REFERENCE);
}
index = (index + step) & (hash_size - 1);
- JvAssert (index != start_index);
}
+ while (index != start_index);
+ // Note that we can have INDEX == START_INDEX if the table has no
+ // NULL entries but does have DELETED entries.
+ JvAssert (deleted_index >= 0);
+ return &hash[deleted_index];
}
static void