* src/vm/method.h (methodinfo): Use mutex instead of java object for locking.
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Fri, 22 Aug 2008 10:19:32 +0000 (12:19 +0200)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Fri, 22 Aug 2008 10:19:32 +0000 (12:19 +0200)
Renamed member header to mutex and made it a pointer.
* src/vm/method.c (method_load, method_builtin_new): Allocate new mutex.
(method_free): Free methodinfos mutex.

* src/vm/jit/inline/inline.c: Adapted to above changes.
* src/vm/jit/jit.cpp: Likewise.
* src/vm/loader.cpp: Likewise.

src/vm/jit/inline/inline.c
src/vm/jit/jit.cpp
src/vm/loader.cpp
src/vm/method.c
src/vm/method.h

index 69fbf60217cbd229fecc2924d44971145523ff23..dd439a56e766e2b97ff561ef0fa715ce7f64639b 100644 (file)
@@ -35,6 +35,7 @@
 #include "mm/memory.h"
 
 #include "threads/lock-common.h"
+#include "threads/mutex.hpp"
 #include "threads/thread.hpp"
 
 #include "toolbox/logging.h"
@@ -337,7 +338,7 @@ static bool inline_jit_compile(inline_node *iln)
 
        /* enter a monitor on the method */
 
-       LOCK_MONITOR_ENTER(m);
+       Mutex_lock(m->mutex);
 
        /* allocate jitdata structure and fill it */
 
@@ -380,7 +381,7 @@ static bool inline_jit_compile(inline_node *iln)
 
        /* leave the monitor */
 
-       LOCK_MONITOR_EXIT(m);
+       Mutex_unlock(m->mutex);
 
        return r;
 }
index 2d5a1da4f11857f3843651b7f71c9f236ed3d401..a664dd42e57b4c0572481848685a579385b81060 100644 (file)
@@ -38,7 +38,7 @@
 
 #include "toolbox/logging.h"
 
-#include "threads/lock-common.h"
+#include "threads/mutex.hpp"
 
 #include "vm/class.h"
 #include "vm/global.h"
@@ -298,12 +298,12 @@ u1 *jit_compile(methodinfo *m)
 
        /* enter a monitor on the method */
 
-       LOCK_MONITOR_ENTER(m);
+       m->mutex->lock();
 
        /* if method has been already compiled return immediately */
 
        if (m->code != NULL) {
-               LOCK_MONITOR_EXIT(m);
+               m->mutex->unlock();
 
                assert(m->code->entrypoint);
                return m->code->entrypoint;
@@ -422,7 +422,7 @@ u1 *jit_compile(methodinfo *m)
 
        /* leave the monitor */
 
-       LOCK_MONITOR_EXIT(m);
+       m->mutex->unlock();
 
        /* return pointer to the methods entry point */
 
index 2c4a5d1ad215443102d7ff5dbdad98b7d40a77ee..b2dcab6f97e48eee7f481d2b44041c471663aab6 100644 (file)
@@ -2162,13 +2162,10 @@ classinfo *load_newly_created_array(classinfo *c, classloader_t *loader)
        clone = c->methods;
        MSET(clone, 0, methodinfo, 1);
 
-#if defined(ENABLE_THREADS)
-       lock_init_object_lock(&clone->header);
-#endif
-
        /* ATTENTION: if you delete the ACC_NATIVE below, set
           clone->maxlocals=1 (interpreter related) */
 
+       clone->mutex      = new Mutex();
        clone->flags      = ACC_PUBLIC | ACC_NATIVE;
        clone->name       = utf_clone;
        clone->descriptor = utf_void__java_lang_Object;
index 1a1cd0ca304a7bda5db05456080a16db9d151b5c..ec71390ebd990f2130c84d08fb103de5830777c7 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "native/llni.h"
 
-#include "threads/lock-common.h"
+#include "threads/mutex.hpp"
 
 #include "vm/array.h"
 #include "vm/jit/builtin.hpp"
@@ -144,7 +144,7 @@ bool method_load(classbuffer *cb, methodinfo *m, descriptor_pool *descpool)
 
        c = cb->clazz;
 
-       LOCK_INIT_OBJECT_LOCK(&(m->header));
+       m->mutex = Mutex_new();
 
 #if defined(ENABLE_STATISTICS)
        if (opt_stat)
@@ -528,6 +528,9 @@ bool method_load(classbuffer *cb, methodinfo *m, descriptor_pool *descpool)
 
 void method_free(methodinfo *m)
 {
+       if (m->mutex)
+               Mutex_delete(m->mutex);
+
        if (m->jcode)
                MFREE(m->jcode, u1, m->jcodelength);
 
@@ -587,8 +590,8 @@ methodinfo *method_new_builtin(builtintable_entry *bte)
        /* initialize methodinfo structure */
 
        MZERO(m, methodinfo, 1);
-       LOCK_INIT_OBJECT_LOCK(&(m->header));
-
+       
+       m->mutex      = Mutex_new();
        m->flags      = ACC_METHOD_BUILTIN;
        m->parseddesc = bte->md;
        m->name       = bte->name;
index ad1d1d6e6d9222aaa6627802b35e56dc1fc76b80..0b9b60dd3943c61b034ebc1f105f1de57568a825 100644 (file)
@@ -42,6 +42,8 @@ typedef struct codeinfo            codeinfo;
 #include "config.h"
 #include "vm/types.h"
 
+#include "threads/mutex.hpp"
+
 #include "vm/jit/builtin.hpp"
 #include "vm/descriptor.h"
 #include "vm/global.h"
@@ -65,7 +67,7 @@ typedef struct codeinfo            codeinfo;
 /* methodinfo *****************************************************************/
 
 struct methodinfo {                 /* method structure                       */
-       java_object_t header;           /* we need this in jit's monitorenter     */
+       Mutex        *mutex;            /* we need this in jit's locking          */
        s4            flags;            /* ACC flags                              */
        utf          *name;             /* name of method                         */
        utf          *descriptor;       /* JavaVM descriptor string of method     */