* src/vm/jit/stack.c (GET_NEW_VAR): Fixed macro argument.
[cacao.git] / src / vm / initialize.c
index 24e98905da297332fd68a93e06abe16389955bb1..c3a86b719c61bc284c48330000e3761b9b5d82bf 100644 (file)
@@ -30,7 +30,7 @@
             Andreas Krall
             Christian Thalinger
 
-   $Id: initialize.c 4357 2006-01-22 23:33:38Z twisti $
+   $Id: initialize.c 5123 2006-07-12 21:45:34Z twisti $
 
 */
 
 
 #include "vm/types.h"
 
+#if defined(ENABLE_THREADS)
+# include "threads/native/lock.h"
+#else
+# include "threads/none/lock.h"
+#endif
+
 #include "vm/global.h"
 #include "vm/initialize.h"
 #include "vm/builtin.h"
@@ -50,6 +56,7 @@
 #include "vm/options.h"
 #include "vm/statistics.h"
 #include "vm/stringlocal.h"
+#include "vm/vm.h"
 #include "vm/jit/asmpart.h"
 
 
@@ -73,19 +80,13 @@ bool initialize_class(classinfo *c)
        if (!makeinitializations)
                return true;
 
-#if defined(USE_THREADS)
-       /* enter a monitor on the class */
-
-       builtin_monitorenter((java_objectheader *) c);
-#endif
+       LOCK_MONITOR_ENTER(c);
 
        /* maybe the class is already initalized or the current thread, which can
           pass the monitor, is currently initalizing this class */
 
        if (CLASS_IS_OR_ALMOST_INITIALIZED(c)) {
-#if defined(USE_THREADS)
-               builtin_monitorexit((java_objectheader *) c);
-#endif
+               LOCK_MONITOR_EXIT(c);
 
                return true;
        }
@@ -96,9 +97,7 @@ bool initialize_class(classinfo *c)
        if (c->state & CLASS_ERROR) {
                *exceptionptr = new_noclassdeffounderror(c->name);
 
-#if defined(USE_THREADS)
-               builtin_monitorexit((java_objectheader *) c);
-#endif
+               LOCK_MONITOR_EXIT(c);
 
                /* ...but return true, this is ok (mauve test) */
 
@@ -123,11 +122,7 @@ bool initialize_class(classinfo *c)
 
        c->state &= ~CLASS_INITIALIZING;
 
-#if defined(USE_THREADS)
-       /* leave the monitor */
-
-       builtin_monitorexit((java_objectheader *) c);
-#endif
+       LOCK_MONITOR_EXIT(c);
 
        return r;
 }
@@ -144,9 +139,6 @@ static bool initialize_class_intern(classinfo *c)
 {
        methodinfo        *m;
        java_objectheader *xptr;
-#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
-       int b;
-#endif
 
        /* maybe the class is not already linked */
 
@@ -198,19 +190,9 @@ static bool initialize_class_intern(classinfo *c)
                log_message_class("Starting static class initializer for class: ", c);
 #endif
 
-#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
-       b = blockInts;
-       blockInts = 0;
-#endif
-
        /* now call the initializer */
 
-       ASM_CALLJAVAFUNCTION(m, NULL, NULL, NULL, NULL);
-
-#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
-       assert(blockInts == 0);
-       blockInts = b;
-#endif
+       (void) vm_call_method(m, NULL);
 
        /* we have an exception or error */