* src/vm/jit/intrp/Makefile.am (Changes): Added my name.
[cacao.git] / src / vm / jit / recompile.c
index 711a1a1d7235d853785902a299562db128ccda1f..a4766e57d39e6a4bd030e2e69573d6ab9bcfa1e8 100644 (file)
@@ -46,6 +46,7 @@
 #include "native/include/java_lang_VMThread.h"
 
 #if defined(ENABLE_THREADS)
+# include "threads/native/lock.h"
 # include "threads/native/threads.h"
 #endif
 
@@ -58,7 +59,7 @@
 
 /* global variables ***********************************************************/
 
-static threadobject *recompile_threadobject;
+static java_lang_VMThread *recompile_vmthread;
 static java_objectheader *lock_recompile_thread;
 static list *list_recompile_methods;
 
@@ -170,7 +171,7 @@ static void recompile_thread(void)
        while (true) {
                /* get the lock on the recompile lock object, so we can call wait */
 
-               builtin_monitorenter(lock_recompile_thread);
+               lock_monitor_enter(lock_recompile_thread);
 
                /* wait forever (0, 0) on that object till we are signaled */
        
@@ -178,18 +179,21 @@ static void recompile_thread(void)
 
                /* leave the lock */
 
-               builtin_monitorexit(lock_recompile_thread);
+               lock_monitor_exit(lock_recompile_thread);
 
                /* get the next method and recompile it */
 
                while ((lme = list_first(list_recompile_methods)) != NULL) {
                        /* recompile this method */
 
-                       (void) jit_recompile(lme->m);
+                       if (jit_recompile(lme->m) != NULL) {
+                               /* replace in vftbl's */
 
-                       /* replace in vftbl's */
-
-                       recompile_replace_vftbl(lme->m);
+                               recompile_replace_vftbl(lme->m);
+                       }
+                       else {
+                               throw_exception();
+                       }
 
                        /* remove the compiled method */
 
@@ -215,19 +219,20 @@ bool recompile_start_thread(void)
 
        /* create the profile object */
 
-       recompile_threadobject = NEW(threadobject);
+       recompile_vmthread =
+               (java_lang_VMThread *) builtin_new(class_java_lang_VMThread);
 
-       if (recompile_threadobject == NULL)
+       if (recompile_vmthread == NULL)
                return false;
 
        t = (java_lang_Thread *) builtin_new(class_java_lang_Thread);
 
-       t->vmThread = (java_lang_VMThread *) recompile_threadobject;
+       t->vmThread = recompile_vmthread;
        t->name     = javastring_new_from_ascii("Recompiler");
        t->daemon   = true;
        t->priority = 5;
 
-       recompile_threadobject->o.thread = t;
+       recompile_vmthread->thread = t;
 
        /* actually start the recompilation thread */
 
@@ -261,7 +266,7 @@ void recompile_queue_method(methodinfo *m)
 
        /* get the lock on the recompile lock object, so we can call notify */
 
-       builtin_monitorenter(lock_recompile_thread);
+       lock_monitor_enter(lock_recompile_thread);
 
        /* signal the recompiler thread */
        
@@ -269,7 +274,7 @@ void recompile_queue_method(methodinfo *m)
 
        /* leave the lock */
 
-       builtin_monitorexit(lock_recompile_thread);
+       lock_monitor_exit(lock_recompile_thread);
 }