#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"
/* global variables ***********************************************************/
#if defined(ENABLE_THREADS)
-static java_object_t *lock_thread_finalizer;
+static Mutex *finalizer_thread_mutex;
+static Condition *finalizer_thread_cond;
#endif
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 */
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)
#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 */
#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"
/* 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 **************************************************************
{
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 */
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 */
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);
}