* src/vm/finalizer.c (finalizer_thread_mutex, finalizer_thread_cond): Use
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Fri, 22 Aug 2008 11:14:07 +0000 (13:14 +0200)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Fri, 22 Aug 2008 11:14:07 +0000 (13:14 +0200)
mutex and condition instead of java object for synchronization.
* src/vm/jit/optimizing/recompile.c (recompile_thread_mutex): Likewise.
(recompile_thread_cond) Likewise.

src/vm/finalizer.c
src/vm/jit/optimizing/recompile.c

index b96743ed40a4c6a4629cf8b386ef2d408c011652..ea331ec96e9c12b7a51d2298d362f8c15ba3af0e 100644 (file)
@@ -31,7 +31,8 @@
 
 #include "mm/memory.h"
 
-#include "threads/lock-common.h"
+#include "threads/condition.hpp"
+#include "threads/mutex.hpp"
 #include "threads/thread.hpp"
 
 #include "vm/jit/builtin.hpp"
@@ -46,7 +47,8 @@
 /* global variables ***********************************************************/
 
 #if defined(ENABLE_THREADS)
-static java_object_t *lock_thread_finalizer;
+static Mutex     *finalizer_thread_mutex;
+static Condition *finalizer_thread_cond;
 #endif
 
 
@@ -61,9 +63,8 @@ bool finalizer_init(void)
        TRACESUBSYSTEMINITIALIZATION("finalizer_init");
 
 #if defined(ENABLE_THREADS)
-       lock_thread_finalizer = NEW(java_object_t);
-
-       LOCK_INIT_OBJECT_LOCK(lock_thread_finalizer);
+       finalizer_thread_mutex = Mutex_new();
+       finalizer_thread_cond  = Condition_new();
 #endif
 
        /* everything's ok */
@@ -84,17 +85,17 @@ bool finalizer_init(void)
 static void finalizer_thread(void)
 {
        while (true) {
-               /* get the lock on the finalizer lock object, so we can call wait */
+               /* get the lock on the finalizer mutex, so we can call wait */
 
-               LOCK_MONITOR_ENTER(lock_thread_finalizer);
+               Mutex_lock(finalizer_thread_mutex);
 
-               /* wait forever on that object till we are signaled */
+               /* wait forever on that condition till we are signaled */
        
-               LOCK_WAIT_FOREVER(lock_thread_finalizer);
+               Condition_wait(finalizer_thread_cond, finalizer_thread_mutex);
 
                /* leave the lock */
 
-               LOCK_MONITOR_EXIT(lock_thread_finalizer);
+               Mutex_unlock(finalizer_thread_mutex);
 
 #if !defined(NDEBUG)
                if (opt_DebugFinalizer)
@@ -154,15 +155,15 @@ void finalizer_notify(void)
 #if defined(ENABLE_THREADS)
        /* get the lock on the finalizer lock object, so we can call wait */
 
-       LOCK_MONITOR_ENTER(lock_thread_finalizer);
+       Mutex_lock(finalizer_thread_mutex);
 
        /* signal the finalizer thread */
-       
-       LOCK_NOTIFY(lock_thread_finalizer);
+
+       Condition_signal(finalizer_thread_cond);
 
        /* leave the lock */
 
-       LOCK_MONITOR_EXIT(lock_thread_finalizer);
+       Mutex_unlock(finalizer_thread_mutex);
 #else
        /* if we don't have threads, just run the finalizers */
 
index 39e75a5e7bdda5b6a3f1ba84b9b19f90164cdfe4..4cd12cd8675cf47ed670d75a22732f358a1c99a5 100644 (file)
@@ -32,7 +32,8 @@
 
 #include "mm/memory.h"
 
-#include "threads/lock-common.h"
+#include "threads/condition.hpp"
+#include "threads/mutex.hpp"
 #include "threads/thread.hpp"
 
 #include "toolbox/list.h"
@@ -51,8 +52,9 @@
 
 /* global variables ***********************************************************/
 
-static java_object_t *lock_thread_recompile;
-static list_t        *list_recompile_methods;
+static Mutex     *recompile_thread_mutex;
+static Condition *recompile_thread_cond;
+static list_t    *list_recompile_methods;
 
 
 /* recompile_init **************************************************************
@@ -65,11 +67,10 @@ bool recompile_init(void)
 {
        TRACESUBSYSTEMINITIALIZATION("recompile_init");
 
-       /* initialize the recompile lock object */
+       /* initialize the recompile thread mutex and condition */
 
-       lock_thread_recompile = NEW(java_object_t);
-
-       LOCK_INIT_OBJECT_LOCK(lock_thread_recompile);
+       recompile_thread_mutex = Mutex_new();
+       recompile_thread_cond  = Condition_new();
 
        /* create method list */
 
@@ -162,17 +163,17 @@ static void recompile_thread(void)
        list_method_entry *lme;
 
        while (true) {
-               /* get the lock on the recompile lock object, so we can call wait */
+               /* get the lock on the recompile mutex, so we can call wait */
+
+               Mutex_lock(recompile_thread_mutex);
 
-               LOCK_MONITOR_ENTER(lock_thread_recompile);
+               /* wait forever on that condition till we are signaled */
 
-               /* wait forever on that object till we are signaled */
-       
-               LOCK_WAIT_FOREVER(lock_thread_recompile);
+               Condition_wait(recompile_thread_cond, recompile_thread_mutex);
 
                /* leave the lock */
 
-               LOCK_MONITOR_EXIT(lock_thread_recompile);
+               Mutex_unlock(recompile_thread_mutex);
 
                /* get the next method and recompile it */
 
@@ -243,17 +244,17 @@ void recompile_queue_method(methodinfo *m)
 
        list_add_last(list_recompile_methods, lme);
 
-       /* get the lock on the recompile lock object, so we can call notify */
+       /* get the lock on the recompile mutex, so we can call notify */
 
-       LOCK_MONITOR_ENTER(lock_thread_recompile);
+       Mutex_lock(recompile_thread_mutex);
 
        /* signal the recompiler thread */
-       
-       LOCK_NOTIFY(lock_thread_recompile);
+
+       Condition_signal(recompile_thread_cond);
 
        /* leave the lock */
 
-       LOCK_MONITOR_EXIT(lock_thread_recompile);
+       Mutex_unlock(recompile_thread_mutex);
 }