* recreated 'default' branch after merging it into 'jitcache-arm-x86'
[cacao.git] / src / vm / string.cpp
index 725879fb0d94db6bd50d5fe41f7c0d4fabd6374e..184f8f66cf742b936a148e9e9b386598f2a4259a 100644 (file)
@@ -27,7 +27,7 @@
 
 #include <assert.h>
 
-#include "vmcore/os.hpp"
+#include "vm/os.hpp"
 
 #include "vm/types.h"
 
 
 #include "mm/memory.h"
 
-#include "native/jni.h"
 #include "native/llni.h"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
 
-#include "vm/array.h"
-#include "vm/builtin.h"
+#include "vm/array.hpp"
+#include "vm/jit/builtin.hpp"
 #include "vm/exceptions.hpp"
+#include "vm/globals.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/options.h"
 #include "vm/primitive.hpp"
+#include "vm/statistics.h"
 #include "vm/string.hpp"
-#include "vm/vm.hpp"
-
-#include "vmcore/globals.hpp"
-#include "vmcore/javaobjects.hpp"
-#include "vmcore/options.h"
-#include "vmcore/statistics.h"
-#include "vmcore/utf8.h"
+#include "vm/utf8.h"
 
 
 /* global variables ***********************************************************/
 
 #define HASHTABLE_STRING_SIZE    2048   /* initial size of javastring-hash    */
 
-hashtable hashtable_string;             /* hashtable for javastrings          */
-
-#if defined(ENABLE_THREADS)
-static java_object_t *lock_hashtable_string;
-#endif
+static hashtable hashtable_string;      /* hashtable for javastrings          */
+static Mutex* mutex;
 
 
 /* string_init *****************************************************************
@@ -81,13 +75,7 @@ bool string_init(void)
 
        hashtable_create(&hashtable_string, HASHTABLE_STRING_SIZE);
 
-#if defined(ENABLE_THREADS)
-       /* create string hashtable lock object */
-
-       lock_hashtable_string = NEW(java_object_t);
-
-       LOCK_INIT_OBJECT_LOCK(lock_hashtable_string);
-#endif
+       mutex = new Mutex();
 
        /* everything's ok */
 
@@ -118,8 +106,7 @@ void stringtable_update(void)
                                
                                if (js.is_null() || (js.get_value() == NULL)) {
                                        /* error in hashtable found */
-
-                                       vm_abort("stringtable_update: invalid literalstring in hashtable");
+                                       os::abort("stringtable_update: invalid literalstring in hashtable");
                                }
 
                                a = LLNI_UNWRAP(js.get_value());
@@ -468,7 +455,7 @@ static java_object_t *literalstring_u2(java_chararray_t *a, int32_t length,
     u4                slot;
     u2                i;
 
-       LOCK_MONITOR_ENTER(lock_hashtable_string);
+       mutex->lock();
 
     /* find location in hashtable */
 
@@ -494,7 +481,7 @@ static java_object_t *literalstring_u2(java_chararray_t *a, int32_t length,
                        if (!copymode)
                                mem_free(a, sizeof(java_chararray_t) + sizeof(u2) * (length - 1) + 10);
 
-                       LOCK_MONITOR_EXIT(lock_hashtable_string);
+                       mutex->unlock();
 
                        return (java_object_t*) LLNI_UNWRAP(js.get_handle());
                }
@@ -535,7 +522,7 @@ static java_object_t *literalstring_u2(java_chararray_t *a, int32_t length,
 #endif
 
 #if defined(ENABLE_THREADS)
-       lock_init_object_lock(o);
+       o->lockword.init();
 #endif
 
        o->vftbl = class_java_lang_String->vftbl;
@@ -601,7 +588,7 @@ static java_object_t *literalstring_u2(java_chararray_t *a, int32_t length,
                hashtable_string = newhash;
        }
 
-       LOCK_MONITOR_EXIT(lock_hashtable_string);
+       mutex->unlock();
 
        return (java_object_t*) LLNI_UNWRAP(jls.get_handle());
 }