* src/toolbox/list.c (list_create): Use Mutex instead of a Java lock.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Thu, 14 Aug 2008 15:30:28 +0000 (17:30 +0200)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Thu, 14 Aug 2008 15:30:28 +0000 (17:30 +0200)
(list_free): Delete the mutex.
(list_lock, list_unlock): Use Mutex functions.
* src/toolbox/list.h (list_t): Use Mutex instead of java_object_t.
* src/vm/jit/patcher-common.c (patcher_handler): Use
list_lock/list_unlock.

src/toolbox/list.c
src/toolbox/list.h
src/vm/jit/patcher-common.c

index 4de7222f628610d7a97a4014c967e1eef48ff0b6..b6187027d78c413e0109d37d06eb7f75fa245d05 100644 (file)
@@ -31,7 +31,7 @@
 
 #include "mm/memory.h"
 
-#include "threads/lock-common.h"
+#include "threads/mutex.hpp"
 
 #include "toolbox/list.h"
 
@@ -48,8 +48,7 @@ list_t *list_create(int nodeoffset)
 
        l = NEW(list_t);
 
-       LOCK_INIT_OBJECT_LOCK(l);
-
+       l->mutex      = Mutex_new();
        l->first      = NULL;
        l->last       = NULL;
        l->nodeoffset = nodeoffset;
@@ -69,6 +68,8 @@ void list_free(list_t *l)
 {
        assert(l != NULL);
 
+       Mutex_delete(l->mutex);
+
        FREE(l, list_t);
 }
 
@@ -87,6 +88,7 @@ list_t *list_create_dump(int nodeoffset)
 
        l = DNEW(list_t);
 
+       l->mutex      = NULL;
        l->first      = NULL;
        l->last       = NULL;
        l->nodeoffset = nodeoffset;
@@ -104,7 +106,7 @@ list_t *list_create_dump(int nodeoffset)
 
 void list_lock(list_t *l)
 {
-       LOCK_MONITOR_ENTER(l);
+       Mutex_lock(l->mutex);
 }
 
 
@@ -116,7 +118,7 @@ void list_lock(list_t *l)
 
 void list_unlock(list_t *l)
 {
-       LOCK_MONITOR_EXIT(l);
+       Mutex_unlock(l->mutex);
 }
 
 
index f93cf1b076fa5721d39242cf7f95032f1db49996..6d3da672117d1043022459beb9452cbc2116b7a5 100644 (file)
 
 #include "config.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <stdint.h>
 
 #include "vm/global.h"
 
+#include "threads/mutex.hpp"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* ---------------------- interface description -----------------------------
 
@@ -109,9 +111,7 @@ struct listnode_t {
 typedef struct list_t list_t;
 
 struct list_t {
-#if defined(ENABLE_THREADS)
-       java_object_t      lock;            /* threads lock object                */
-#endif
+       Mutex*             mutex;           /* threads lock object                */
        listnode_t        *first;
        listnode_t        *last;
        int                nodeoffset;
index 93931db173d7b976a9579db60d946d84c737faa2..c6e2da2c79ac3018a8d6c199b281258c7be34425 100644 (file)
@@ -36,8 +36,6 @@
 
 #include "native/native.h"
 
-#include "threads/lock-common.h"
-
 #include "toolbox/list.h"
 #include "toolbox/logging.h"           /* XXX remove me! */
 
@@ -333,7 +331,7 @@ java_handle_t *patcher_handler(u1 *pc)
 
        /* enter a monitor on the patcher list */
 
-       LOCK_MONITOR_ENTER(code->patchers);
+       list_lock(code->patchers);
 
        /* search the patcher information for the given PC */
 
@@ -348,7 +346,7 @@ java_handle_t *patcher_handler(u1 *pc)
                        log_println("patcher_handler: double-patching detected!");
                }
 #endif
-               LOCK_MONITOR_EXIT(code->patchers);
+               list_unlock(code->patchers);
                return NULL;
        }
 
@@ -408,14 +406,14 @@ java_handle_t *patcher_handler(u1 *pc)
        if (result == false) {
                e = exceptions_get_and_clear_exception();
 
-               LOCK_MONITOR_EXIT(code->patchers);
+               list_unlock(code->patchers);
 
                return e;
        }
 
        pr->done = true; /* XXX this is only preliminary to prevent double-patching */
 
-       LOCK_MONITOR_EXIT(code->patchers);
+       list_unlock(code->patchers);
 
        return NULL;
 }