for locking. Renamed member lock to mutex.
* src/toolbox/hashtable.c: Adapted to above change.
* src/native/jni.cpp: Likewise.
* src/native/native.c: Likewise.
* src/vm/loader.cpp: Likewise.
* src/vm/utf8.c: Likewise.
* src/vm/zip.c: Added include to prevent circular dependency with hashtable.
#endif
#include "threads/lock-common.h"
+#include "threads/mutex.hpp"
#include "threads/thread.hpp"
#include "toolbox/logging.h"
o = (java_handle_t *) obj;
- LOCK_MONITOR_ENTER(hashtable_global_ref->header);
+ hashtable_global_ref->mutex->lock();
LLNI_CRITICAL_START;
hashtable_global_ref->entries++;
}
- LOCK_MONITOR_EXIT(hashtable_global_ref->header);
+ hashtable_global_ref->mutex->unlock();
#if defined(ENABLE_HANDLES)
return gre;
o = (java_handle_t *) globalRef;
- LOCK_MONITOR_ENTER(hashtable_global_ref->header);
+ hashtable_global_ref->mutex->lock();
LLNI_CRITICAL_START;
LLNI_CRITICAL_END;
- LOCK_MONITOR_EXIT(hashtable_global_ref->header);
+ hashtable_global_ref->mutex->unlock();
return;
}
LLNI_CRITICAL_END;
- LOCK_MONITOR_EXIT(hashtable_global_ref->header);
+ hashtable_global_ref->mutex->unlock();
}
#include "native/vm/nativevm.h"
-#include "threads/lock-common.h"
+#include "threads/mutex.hpp"
#include "toolbox/avl.h"
#include "toolbox/hashtable.h"
u4 key; /* hashkey */
u4 slot; /* slot in hashtable */
- LOCK_MONITOR_ENTER(hashtable_library->header);
+ Mutex_lock(hashtable_library->mutex);
/* normally addresses are aligned to 4, 8 or 16 bytes */
while (ne) {
if (ne->name == filename) {
- LOCK_MONITOR_EXIT(hashtable_library->header);
+ Mutex_unlock(hashtable_library->mutex);
return;
}
ne->hashlink = le->namelink;
le->namelink = ne;
- LOCK_MONITOR_EXIT(hashtable_library->header);
+ Mutex_unlock(hashtable_library->mutex);
}
#endif
#include "mm/memory.h"
-#include "threads/lock-common.h"
+#include "threads/mutex.hpp"
#include "toolbox/hashtable.h"
Initializes a hashtable structure and allocates memory. The
parameter size specifies the initial size of the hashtable.
-
+
*******************************************************************************/
void hashtable_create(hashtable *hash, u4 size)
/* initialize locking pointer */
#if defined(ENABLE_THREADS)
- /* We need to seperately allocate a java_object_t here, as we
- need to store the lock object in the new hashtable if it's
- resized. Otherwise we get an IllegalMonitorStateException. */
-
- hash->header = NEW(java_object_t);
+ /* We need to seperately allocate a mutex here, as we need to
+ store the lock object in the new hashtable if it's resized.
+ Otherwise we get an IllegalMonitorStateException. */
- LOCK_INIT_OBJECT_LOCK(hash->header);
+ hash->mutex = Mutex_new();
#endif
/* set initial hash values */
/* We need to store the old lock object in the new hashtable.
Otherwise we get an IllegalMonitorStateException. */
- FREE(newhash->header, java_object_t);
+ Mutex_delete(newhash->mutex);
- newhash->header = hash->header;
+ newhash->mutex = hash->mutex;
#endif
/* store the number of entries in the new hashtable */
#include "config.h"
#include "vm/types.h"
+#include "threads/mutex.hpp"
+
#include "vm/global.h"
#include "vm/utf8.h"
struct hashtable {
#if defined(ENABLE_THREADS)
- java_object_t *header; /* required for locking */
+ Mutex *mutex; /* required for locking */
#endif
u4 size; /* current size of the hashtable */
u4 entries; /* number of entries in the table */
#include "native/llni.h"
#include "threads/lock-common.h"
+#include "threads/mutex.hpp"
#include "toolbox/hashtable.h"
#include "toolbox/logging.h"
if (cl == NULL)
return NULL;
- LOCK_MONITOR_ENTER(hashtable_classloader->header);
+ hashtable_classloader->mutex->lock();
LLNI_CRITICAL_START;
hashtable_classloader->entries++;
}
-
- LOCK_MONITOR_EXIT(hashtable_classloader->header);
+ hashtable_classloader->mutex->unlock();
#if defined(ENABLE_HANDLES)
return cle;
#include "mm/memory.h"
-#include "threads/lock-common.h"
+#include "threads/mutex.hpp"
#include "toolbox/hashtable.h"
utf *u; /* hashtable element */
u2 i;
- LOCK_MONITOR_ENTER(hashtable_utf->header);
+ Mutex_lock(hashtable_utf->mutex);
#if defined(ENABLE_STATISTICS)
if (opt_stat)
/* symbol found in hashtable */
- LOCK_MONITOR_EXIT(hashtable_utf->header);
+ Mutex_unlock(hashtable_utf->mutex);
return u;
}
hashtable_utf = newhash;
}
- LOCK_MONITOR_EXIT(hashtable_utf->header);
+ Mutex_unlock(hashtable_utf->mutex);
return u;
}
u4 left; /* unicode characters left */
u4 buflength; /* utf length in bytes of the u2 array */
utf *result; /* resulting utf-string */
- int i;
+ int i;
/* determine utf length in bytes and allocate memory */
#include "vm/types.h"
+#include "vm/descriptor.h" /* needed to prevent circular dependency */
#include "toolbox/hashtable.h"
#include "mm/memory.h"