* vm/tables.h: Renamed to vm/hashtable.h.
authortwisti <none@none>
Thu, 1 Dec 2005 23:50:28 +0000 (23:50 +0000)
committertwisti <none@none>
Thu, 1 Dec 2005 23:50:28 +0000 (23:50 +0000)
* lock_classcache_hashtable: Renamed to lock_hashtable_classcache.
* classcache_init: Added hashtable_create of hashtable_classcache.

src/vm/classcache.c
src/vm/classcache.h

index 71b4ce0b8c039bfadee92a42a110087c753b4ce0..fd9cb49217d5d2a0167d4befa6fbba40a5fdc373 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: classcache.c 3814 2005-11-28 18:51:26Z edwin $
+   $Id: classcache.c 3837 2005-12-01 23:50:28Z twisti $
 
 */
 
@@ -41,8 +41,8 @@
 #include "mm/memory.h"
 #include "vm/classcache.h"
 #include "vm/exceptions.h"
+#include "vm/hashtable.h"
 #include "vm/stringlocal.h"
-#include "vm/tables.h"
 #include "vm/utf8.h"
 
 
@@ -65,8 +65,8 @@
        /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
 
 #if defined(USE_THREADS)
-# define CLASSCACHE_LOCK()      builtin_monitorenter(lock_classcache_hashtable)
-# define CLASSCACHE_UNLOCK()    builtin_monitorexit(lock_classcache_hashtable)
+# define CLASSCACHE_LOCK()      builtin_monitorenter(lock_hashtable_classcache)
+# define CLASSCACHE_UNLOCK()    builtin_monitorexit(lock_hashtable_classcache)
 #else
 # define CLASSCACHE_LOCK()
 # define CLASSCACHE_UNLOCK()
 /* GLOBAL VARIABLES                                                           */
 /*============================================================================*/
 
+hashtable hashtable_classcache;
+
 #if defined(USE_THREADS)
-static java_objectheader *lock_classcache_hashtable;
+static java_objectheader *lock_hashtable_classcache;
 #endif
 
-hashtable classcache_hash;
 
 /*============================================================================*/
 /*                                                                            */
@@ -96,18 +97,20 @@ hashtable classcache_hash;
 
 bool classcache_init(void)
 {
+       /* create the hashtable */
+
+       hashtable_create(&hashtable_classcache, CLASSCACHE_INIT_SIZE);
+
 #if defined(USE_THREADS)
        /* create utf hashtable lock object */
 
-       lock_classcache_hashtable = NEW(java_objectheader);
+       lock_hashtable_classcache = NEW(java_objectheader);
 
 # if defined(NATIVE_THREADS)
-       initObjectLock(lock_classcache_hashtable);
+       initObjectLock(lock_hashtable_classcache);
 # endif
 #endif
 
-       init_hashtable(&classcache_hash, CLASSCACHE_INIT_SIZE);
-
        /* everything's ok */
 
        return true;
@@ -218,8 +221,8 @@ static classcache_name_entry *classcache_lookup_name(utf *name)
 /*     u4 i; */
 
        key  = utf_hashkey(name->text, (u4) name->blength);
-       slot = key & (classcache_hash.size - 1);
-       c    = classcache_hash.ptr[slot];
+       slot = key & (hashtable_classcache.size - 1);
+       c    = hashtable_classcache.ptr[slot];
 
        /* search external hash chain for the entry */
 
@@ -260,8 +263,8 @@ static classcache_name_entry *classcache_new_name(utf *name)
        u4 i;
 
        key  = utf_hashkey(name->text, (u4) name->blength);
-       slot = key & (classcache_hash.size - 1);
-       c    = classcache_hash.ptr[slot];
+       slot = key & (hashtable_classcache.size - 1);
+       c    = hashtable_classcache.ptr[slot];
 
        /* search external hash chain for the entry */
 
@@ -282,13 +285,13 @@ static classcache_name_entry *classcache_new_name(utf *name)
        c->classes = NULL;
 
        /* insert entry into hashtable */
-       c->hashlink = (classcache_name_entry *) classcache_hash.ptr[slot];
-       classcache_hash.ptr[slot] = c;
+       c->hashlink = (classcache_name_entry *) hashtable_classcache.ptr[slot];
+       hashtable_classcache.ptr[slot] = c;
 
        /* update number of hashtable-entries */
-       classcache_hash.entries++;
+       hashtable_classcache.entries++;
 
-       if (classcache_hash.entries > (classcache_hash.size * 2)) {
+       if (hashtable_classcache.entries > (hashtable_classcache.size * 2)) {
 
                /* reorganization of hashtable, average length of 
                   the external chains is approx. 2                */
@@ -298,13 +301,13 @@ static classcache_name_entry *classcache_new_name(utf *name)
 
                /* create new hashtable, double the size */
 
-               init_hashtable(&newhash, classcache_hash.size * 2);
-               newhash.entries = classcache_hash.entries;
+               hashtable_create(&newhash, hashtable_classcache.size * 2);
+               newhash.entries = hashtable_classcache.entries;
 
                /* transfer elements to new hashtable */
 
-               for (i = 0; i < classcache_hash.size; i++) {
-                       c2 = (classcache_name_entry *) classcache_hash.ptr[i];
+               for (i = 0; i < hashtable_classcache.size; i++) {
+                       c2 = (classcache_name_entry *) hashtable_classcache.ptr[i];
                        while (c2) {
                                classcache_name_entry *nextc = c2->hashlink;
                                u4 newslot =
@@ -319,8 +322,8 @@ static classcache_name_entry *classcache_new_name(utf *name)
 
                /* dispose old table */
 
-               MFREE(classcache_hash.ptr, void *, classcache_hash.size);
-               classcache_hash = newhash;
+               MFREE(hashtable_classcache.ptr, void *, hashtable_classcache.size);
+               hashtable_classcache = newhash;
        }
 
        return c;
@@ -852,17 +855,17 @@ void classcache_free(void)
        classcache_name_entry *entry;
        classcache_name_entry *next;
 
-       for (slot = 0; slot < classcache_hash.size; ++slot) {
-               for (entry = (classcache_name_entry *) classcache_hash.ptr[slot]; entry; entry = next) {
+       for (slot = 0; slot < hashtable_classcache.size; ++slot) {
+               for (entry = (classcache_name_entry *) hashtable_classcache.ptr[slot]; entry; entry = next) {
                        next = entry->hashlink;
                        classcache_free_name_entry(entry);
                }
        }
 
-       MFREE(classcache_hash.ptr, voidptr, classcache_hash.size);
-       classcache_hash.size = 0;
-       classcache_hash.entries = 0;
-       classcache_hash.ptr = NULL;
+       MFREE(hashtable_classcache.ptr, voidptr, hashtable_classcache.size);
+       hashtable_classcache.size = 0;
+       hashtable_classcache.entries = 0;
+       hashtable_classcache.ptr = NULL;
 }
 
 /* classcache_add_constraint ***************************************************
@@ -1008,12 +1011,12 @@ void classcache_debug_dump(FILE * file)
        CLASSCACHE_LOCK();
 
        fprintf(file, "\n=== [loaded class cache] =====================================\n\n");
-       fprintf(file, "hash size   : %d\n", (int) classcache_hash.size);
-       fprintf(file, "hash entries: %d\n", (int) classcache_hash.entries);
+       fprintf(file, "hash size   : %d\n", (int) hashtable_classcache.size);
+       fprintf(file, "hash entries: %d\n", (int) hashtable_classcache.entries);
        fprintf(file, "\n");
 
-       for (slot = 0; slot < classcache_hash.size; ++slot) {
-               c = (classcache_name_entry *) classcache_hash.ptr[slot];
+       for (slot = 0; slot < hashtable_classcache.size; ++slot) {
+               c = (classcache_name_entry *) hashtable_classcache.ptr[slot];
 
                for (; c; c = c->hashlink) {
                        utf_fprint_classname(file, c->name);
index 04c5411a55a3f2ecc6080ddecced12699038a517..10033d3148b564cc98213c70abdf4f0bf7b6272e 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: classcache.h 3814 2005-11-28 18:51:26Z edwin $
+   $Id: classcache.h 3837 2005-12-01 23:50:28Z twisti $
 
 */
 
 
 #include <stdio.h>  /* for FILE */
 
+#include "config.h"
+#include "vm/types.h"
+
+#include "vm/hashtable.h"
 #include "vm/references.h"
-#include "vm/tables.h"
 
 
 /* forward declarations *******************************************************/
@@ -52,10 +55,10 @@ typedef java_objectheader classloader;
 
 /* global variables ***********************************************************/
 
-extern hashtable classcache_hash;
+extern hashtable hashtable_classcache;
 
-/* structs ********************************************************************/
 
+/* structs ********************************************************************/
 
 /*----------------------------------------------------------------------------*/
 /* The Loaded Class Cache                                                     */
@@ -115,6 +118,7 @@ struct classcache_loader_entry
        classcache_loader_entry  *next;       /* next loader entry in the list    */
 };
 
+
 /* function prototypes ********************************************************/
 
 /* initialize the loaded class cache */