* src/vm/string.c: Moved to .cpp.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Tue, 22 Jul 2008 14:48:50 +0000 (16:48 +0200)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Tue, 22 Jul 2008 14:48:50 +0000 (16:48 +0200)
* src/vm/stringlocal.h: Likewise.
* src/vm/string.cpp: New file.
* src/vm/string.hpp: Likewise.
* src/vm/Makefile.am (libvm_la_SOURCES): Changed filenames.
* src/cacaoh/cacaoh.c,
src/cacaoh/headers.c,
src/mm/cacao-gc/heap.c,
src/mm/gc-boehm.cpp,
src/mm/gc-none.cpp,
src/mm/memory.c,
src/native/jni.cpp,
src/native/jvmti/cacaodbg.c,
src/native/jvmti/jvmti.c,
src/native/native.c,
src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c,
src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c,
src/native/vm/cldc1.1/java_lang_String.c,
src/native/vm/cldc1.1/java_lang_System.c,
src/native/vm/gnuclasspath/java_lang_VMClass.cpp,
src/native/vm/gnuclasspath/java_lang_VMClassLoader.cpp,
src/native/vm/gnuclasspath/java_lang_VMRuntime.c,
src/native/vm/gnuclasspath/java_lang_VMString.c,
src/native/vm/gnuclasspath/java_lang_VMThread.c,
src/native/vm/gnuclasspath/java_lang_VMThrowable.cpp,
src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.cpp,
src/native/vm/gnuclasspath/java_lang_reflect_VMField.cpp,
src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.cpp,
src/native/vm/gnuclasspath/sun_reflect_ConstantPool.cpp,
src/native/vm/openjdk/jvm.c,
src/native/vm/reflect.c,
src/native/vm/sun_misc_Unsafe.cpp,
src/threads/posix/lock.c,
src/threads/posix/thread-posix.cpp,
src/threads/thread.cpp,
src/vm/builtin.c,
src/vm/exceptions.cpp,
src/vm/finalizer.c,
src/vm/initialize.c,
src/vm/jit/allocator/lsra.c,
src/vm/jit/allocator/simplereg.c,
src/vm/jit/alpha/freebsd/md-os.c,
src/vm/jit/arm/linux/md-os.c,
src/vm/jit/codegen-common.c,
src/vm/jit/i386/codegen.c,
src/vm/jit/i386/cygwin/md-os.c,
src/vm/jit/i386/darwin/md-os.c,
src/vm/jit/i386/linux/md-os.c,
src/vm/jit/i386/solaris/md-os.c,
src/vm/jit/intrp/codegen.c,
src/vm/jit/m68k/codegen.c,
src/vm/jit/mips/emit.c,
src/vm/jit/mips/irix/md-os.c,
src/vm/jit/optimizing/lifetimes.c,
src/vm/jit/optimizing/profile.c,
src/vm/jit/optimizing/recompile.c,
src/vm/jit/parse.c,
src/vm/jit/powerpc/codegen.c,
src/vm/jit/powerpc/darwin/md-os.c,
src/vm/jit/powerpc/linux/md-os.c,
src/vm/jit/powerpc/netbsd/md-os.c,
src/vm/jit/powerpc64/codegen.c,
src/vm/jit/replace.c,
src/vm/jit/s390/codegen.c,
src/vm/jit/show.c,
src/vm/jit/sparc64/emit.c,
src/vm/jit/sparc64/linux/md-os.c,
src/vm/jit/sparc64/md.c,
src/vm/jit/sparc64/solaris/md-os.c,
src/vm/jit/stack.c,
src/vm/jit/stacktrace.cpp,
src/vm/jit/trace.cpp,
src/vm/jit/x86_64/codegen.c,
src/vm/package.cpp,
src/vm/properties.c,
src/vm/vm.cpp,
src/vmcore/class.h,
src/vmcore/field.c,
src/vmcore/linker.c,
src/vmcore/loader.c: Changed include.

--HG--
rename : src/vm/string.c => src/vm/string.cpp
rename : src/vm/stringlocal.h => src/vm/string.hpp

80 files changed:
src/cacaoh/cacaoh.c
src/cacaoh/headers.c
src/mm/cacao-gc/heap.c
src/mm/gc-boehm.cpp
src/mm/gc-none.cpp
src/mm/memory.c
src/native/jni.cpp
src/native/jvmti/cacaodbg.c
src/native/jvmti/jvmti.c
src/native/native.c
src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c
src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c
src/native/vm/cldc1.1/java_lang_String.c
src/native/vm/cldc1.1/java_lang_System.c
src/native/vm/gnuclasspath/java_lang_VMClass.cpp
src/native/vm/gnuclasspath/java_lang_VMClassLoader.cpp
src/native/vm/gnuclasspath/java_lang_VMRuntime.c
src/native/vm/gnuclasspath/java_lang_VMString.c
src/native/vm/gnuclasspath/java_lang_VMThread.c
src/native/vm/gnuclasspath/java_lang_VMThrowable.cpp
src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.cpp
src/native/vm/gnuclasspath/java_lang_reflect_VMField.cpp
src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.cpp
src/native/vm/gnuclasspath/sun_reflect_ConstantPool.cpp
src/native/vm/openjdk/jvm.c
src/native/vm/reflect.c
src/native/vm/sun_misc_Unsafe.cpp
src/threads/posix/lock.c
src/threads/posix/thread-posix.cpp
src/threads/thread.cpp
src/vm/Makefile.am
src/vm/builtin.c
src/vm/exceptions.cpp
src/vm/finalizer.c
src/vm/initialize.c
src/vm/jit/allocator/lsra.c
src/vm/jit/allocator/simplereg.c
src/vm/jit/alpha/freebsd/md-os.c
src/vm/jit/arm/linux/md-os.c
src/vm/jit/codegen-common.c
src/vm/jit/i386/codegen.c
src/vm/jit/i386/cygwin/md-os.c
src/vm/jit/i386/darwin/md-os.c
src/vm/jit/i386/linux/md-os.c
src/vm/jit/i386/solaris/md-os.c
src/vm/jit/intrp/codegen.c
src/vm/jit/m68k/codegen.c
src/vm/jit/mips/emit.c
src/vm/jit/mips/irix/md-os.c
src/vm/jit/optimizing/lifetimes.c
src/vm/jit/optimizing/profile.c
src/vm/jit/optimizing/recompile.c
src/vm/jit/parse.c
src/vm/jit/powerpc/codegen.c
src/vm/jit/powerpc/darwin/md-os.c
src/vm/jit/powerpc/linux/md-os.c
src/vm/jit/powerpc/netbsd/md-os.c
src/vm/jit/powerpc64/codegen.c
src/vm/jit/replace.c
src/vm/jit/s390/codegen.c
src/vm/jit/show.c
src/vm/jit/sparc64/emit.c
src/vm/jit/sparc64/linux/md-os.c
src/vm/jit/sparc64/md.c
src/vm/jit/sparc64/solaris/md-os.c
src/vm/jit/stack.c
src/vm/jit/stacktrace.cpp
src/vm/jit/trace.cpp
src/vm/jit/x86_64/codegen.c
src/vm/package.cpp
src/vm/properties.c
src/vm/string.c [deleted file]
src/vm/string.cpp [new file with mode: 0644]
src/vm/string.hpp [new file with mode: 0644]
src/vm/stringlocal.h [deleted file]
src/vm/vm.cpp
src/vmcore/class.h
src/vmcore/field.c
src/vmcore/linker.c
src/vmcore/loader.c

index e47bbb62f26487cfec6783feff1b0fd235e97549..bd7d38cb92211c99ae3f636531c2a1fcdff68e38 100644 (file)
@@ -40,7 +40,7 @@
 #include "toolbox/logging.h"
 
 #include "vm/global.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vmcore/classcache.h"
index c5b799d3a9bc0c6eb06fc7f218fd49a45f7058d1..6f2ec0b5a42d075ab52487ff7040be798c14d43d 100644 (file)
@@ -47,7 +47,7 @@
 
 #include "vm/builtin.h"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vmcore/class.h"
 #include "vmcore/method.h"
index ae5adfd36fcbdc86c50e3d1a3de53a12c533d795..49a26cb245d13bb8568beca07ad0d2577768443e 100644 (file)
@@ -1,9 +1,7 @@
 /* mm/cacao-gc/heap.c - GC module for heap management
 
-   Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
+   Copyright (C) 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
@@ -40,7 +38,7 @@
 #include "native/llni.h"
 #include "toolbox/logging.h"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 #include "vmcore/options.h"
 #include "vmcore/rt-timing.h"
index 39cfb64a52f45197fcb6b2fa834c032e4e56c515..04c6367ddb7f29aee4f9b0a402a7af06bd02b809 100644 (file)
@@ -47,7 +47,7 @@
 #include "vm/exceptions.hpp"
 #include "vm/finalizer.h"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vmcore/loader.h"
index 54b3e7b26f0fe660d5bb24c67420d19114418f89..0a799e18e419100dbda6d0c47c7b2679cff471d0 100644 (file)
@@ -42,7 +42,6 @@
 
 #include "vm/builtin.h"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
 #include "vm/vm.hpp"
 
 #include "vmcore/loader.h"
index 6a8ec8ee33beeeba4ea9e2c03fe29228a80fac13..dc0d43502463bb97b41db67b407a2fbb94c42ec3 100644 (file)
@@ -52,7 +52,7 @@
 #include "toolbox/logging.h"
 
 #include "vm/global.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vmcore/options.h"
index b5ef9665d2f29270caba37d98ae2f383d4f9cd89..42d80811ad8ea4fb3f6a15fd01a9993014a962ce 100644 (file)
@@ -107,7 +107,7 @@ struct java_lang_ClassLoader;
 #include "vm/initialize.h"
 #include "vm/primitive.hpp"
 #include "vm/resolve.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vm/jit/argument.h"
index 370557d4eab684b3ab165e5dc012292e03f1811e..ced10d58fa02060213e106d1e08615432943296e 100644 (file)
@@ -31,7 +31,7 @@
 #include "vm/exceptions.hpp"
 #include "vm/builtin.h"
 #include "vm/jit/asmpart.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "toolbox/logging.h"
 #include "threads/mutex.h"
 #include "threads/thread.hpp"
index 1d3d5f1565f4c99249a0c2c3feafd5c0faca2fe1..49e7f795c24be6a4e5819a26b70d4631fafeaa0a 100644 (file)
@@ -50,7 +50,7 @@
 #include "mm/gc.hpp"
 #include "toolbox/logging.h"
 #include "vm/options.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "mm/memory.h"
 #include "threads/mutex.h"
 #include "threads/thread.hpp"
index 6876dbcc2d0d3d73f1a6d1a693638167072bf0d0..5a5c98260671447ab5fb7a71125d8e12a38e67cc 100644 (file)
@@ -49,7 +49,7 @@
 #include "vm/exceptions.hpp"
 #include "vm/global.h"
 #include "vm/resolve.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
index 6106c8c7fef28da940352b74bd6d458dc328158d..c0370fa6a87c3841d4b32b3899b7d827f72d3548 100644 (file)
@@ -46,7 +46,7 @@
 #include "vm/builtin.h"
 #include "vm/vm.hpp" /* REMOVE ME: temporarily */
 #include "vm/exceptions.hpp"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vmcore/zip.h"
 
index 0cf59f50d2d3bfe5af7b55c5c9a1fc72fe828a5e..c8f7187b2f339fd9730ee23e0ec3dd725da2f8fc 100644 (file)
@@ -34,7 +34,7 @@
 #include "native/include/com_sun_cldchi_jvm_JVM.h"
 
 #include "vm/exceptions.hpp"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 
 /* native methods implemented by this file ************************************/
index c0ba6ad5726408f6a50617f706edc55c6e667c1b..0e65859783008960b957eb1d5928ab65572c646f 100644 (file)
@@ -1,9 +1,7 @@
 /* src/native/vm/cldc1.1/java_lang_String.c
 
-   Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates,
-   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
-   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
-   Institut f. Computersprachen - TU Wien
+   Copyright (C) 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
@@ -40,7 +38,7 @@
 
 #include "native/include/java_lang_String.h"
 
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 
 /* native methods implemented by this file ************************************/
index 7a14f9e5247a52791b2df95a8d478d8d7c22442f..1e00f9bfe7ee31f317cb11c1416936a8df41d911 100644 (file)
@@ -1,9 +1,7 @@
 /* src/native/vm/cldc1.1/java_lang_System.c
 
-   Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates,
-   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
-   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
-   Institut f. Computersprachen - TU Wien
+   Copyright (C) 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
@@ -43,7 +41,7 @@
 
 #include "vm/builtin.h"
 #include "vm/properties.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 
 /* native methods implemented by this file ************************************/
index e6f5cfca0d0c620fb84fc94b98d3075af2942373..0714944b2ab1b7c34956d57236e48880693dcc2d 100644 (file)
@@ -46,7 +46,7 @@ extern "C" {
 
 #include "vm/exceptions.hpp"
 #include "vm/initialize.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vmcore/class.h"
 #include "vmcore/globals.hpp"
index a6c3e8906a4656559f92ff05209c9d517bdb92fb..1e0473520f29accab2994cbb25a056a14c549069 100644 (file)
@@ -58,7 +58,7 @@ extern "C" {
 #include "vm/exceptions.hpp"
 #include "vm/initialize.h"
 #include "vm/primitive.hpp"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
index b0259e9d59641c4e07c69604f82fbb758ffdf52c..73a96c52bb62f8123cea7b80c680a5f751fb59cf 100644 (file)
@@ -1,4 +1,4 @@
-/* src/native/vm/gnu/java_lang_VMRuntime.c
+/* src/native/vm/gnuclasspath/java_lang_VMRuntime.c
 
    Copyright (C) 1996-2005, 2006, 2007, 2008
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
@@ -53,7 +53,7 @@
 
 #include "vm/builtin.h"
 #include "vm/exceptions.hpp"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vmcore/system.h"
index 993b6616c68588aa96bba4d476b28e92ae3aa45e..d181da801cea9ba28c74e62d215746734e4ca933 100644 (file)
@@ -1,9 +1,7 @@
-/* src/native/vm/gnu/java_lang_VMString.c - java/lang/VMString
+/* src/native/vm/gnuclasspath/java_lang_VMString.c - java/lang/VMString
 
-   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
@@ -35,7 +33,7 @@
 #include "native/include/java_lang_String.h"
 #include "native/include/java_lang_VMString.h"
 
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 
 /* native methods implemented by this file ************************************/
index 6667d17d599e53a49bfaf1100cd366eec632bc49..fa5f092461de5483296163d9edf83f6655f7c5c3 100644 (file)
@@ -42,7 +42,7 @@
 #include "threads/thread.hpp"
 
 #include "vm/exceptions.hpp"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vmcore/utf8.h"
 
index b17062610dcc4d5c80ae15ef692fb651c13812dc..eaff3364ce531908a59307587c60654cc8f75d22 100644 (file)
@@ -48,7 +48,7 @@ extern "C" {
 #include "vm/array.h"
 #include "vm/builtin.h"
 #include "vm/exceptions.hpp"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vm/jit/code.h"
 #include "vm/jit/linenumbertable.h"
index a7ca0e7ea01d43647174cc295aa809bddab8336a..2f95131796385004f824b9d1cf532c9a83b8e624 100644 (file)
@@ -49,7 +49,7 @@ extern "C" {
 
 #include "native/vm/reflect.h"
 
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vmcore/utf8.h"
 
index 0f4070ab4b2eb7c886a7b58f78c8b668e2effe2f..c30ad41cc269bf375e5fa03a5c1328ccf1e76d38 100644 (file)
@@ -64,7 +64,7 @@ extern "C" {
 #include "vm/initialize.h"
 #include "vm/primitive.hpp"
 #include "vm/resolve.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vmcore/loader.h"
 #include "vmcore/utf8.h"
index d07b2e203651253fb2c4d144e10c2e4f93cf5e62..168161276020a9fa9a4cce0527660056617b1c29 100644 (file)
@@ -59,7 +59,7 @@ extern "C" {
 #include "vm/exceptions.hpp"
 #include "vm/initialize.h"
 #include "vm/resolve.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vmcore/globals.hpp"
 #include "vmcore/method.h"
index 2eb68da51b49bf250b681f0ad1d63ec8634a67d3..30f2eebd674779179016750c83f70eedf2e4b6ee 100644 (file)
@@ -61,7 +61,7 @@ extern "C" {
 #include "vm/vm.hpp"
 #include "vm/exceptions.hpp"
 #include "vm/resolve.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vmcore/class.h"
 #include "vmcore/utf8.h"
index 78819739812e8fa62b07bebf83ab7c895e51125e..2195069872573af3734c59961b67374a8febf207 100644 (file)
@@ -86,7 +86,7 @@
 #include "vm/properties.h"
 #include "vm/resolve.h"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vm/jit/stacktrace.hpp"
index fd563bb9ce00120a215485fb4703e3ce2edec16d..c1108bb2c04527949dedfb9b617505f3f0338287 100644 (file)
@@ -64,7 +64,7 @@
 #include "vm/exceptions.hpp"
 #include "vm/global.h"
 #include "vm/initialize.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vmcore/globals.hpp"
 #include "vmcore/method.h"
index 39096ef8ca47fbd83f5b3a11afab34e515a9591a..9077150104603a4f89ed88645a62bd2a2b441615 100644 (file)
@@ -63,7 +63,7 @@ extern "C" {
 #include "vm/builtin.h"
 #include "vm/exceptions.hpp"
 #include "vm/initialize.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vmcore/system.h"
 #include "vmcore/utf8.h"
index 17b067215f6e3902567b9761f0f0de76f29979ee..79f42c14b9e4dbec7189501be4a78ac4c342d696 100644 (file)
@@ -50,7 +50,7 @@
 #include "vm/global.h"
 #include "vm/exceptions.hpp"
 #include "vm/finalizer.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vmcore/options.h"
index 7afa711edc7a9fd2899bcf7f13b81aaabf8102e9..4479fae449a16c24601b8c9a9d6b7997b17d3b85 100644 (file)
@@ -78,7 +78,7 @@
 #include "vm/builtin.h"
 #include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
index d6cea1793c6a197849d89c325df2e898ee1374b9..9011a6321b04db64a60ce104c120d769db59114c 100644 (file)
@@ -61,7 +61,7 @@
 
 #include "vm/builtin.h"
 #include "vm/exceptions.hpp"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vm/jit/stacktrace.hpp"
index ce612f2dc5238204fda762bc44b74ea5d8e23d9a..1255eca995f5c604fdec8586aba37cc2d72ee79d 100644 (file)
@@ -73,8 +73,8 @@ libvm_la_SOURCES = \
        resolve.h \
        signal.c \
        signallocal.h \
-       string.c \
-       stringlocal.h \
+       string.cpp \
+       string.hpp \
        vm.cpp \
        vm.hpp
 
index d9d7d62180c5b15b20e1989f712ce2313ac1b4b2..4225468835be4c960a383ba816e4eebfcb67edac 100644 (file)
@@ -66,7 +66,7 @@
 #include "vm/global.h"
 #include "vm/initialize.h"
 #include "vm/primitive.hpp"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/trace.hpp"
index 165371012323163f96e08e4b3d0a4207285836cd..b528bb98fda6bedb85fd640a967b831f4fb8311a 100644 (file)
@@ -53,7 +53,7 @@
 #include "vm/builtin.h"
 #include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
index 5d7e06a1c026175aea460d4e676565c232fdf0a5..7c5faee952c7153b28a0207b300e16181f707b5c 100644 (file)
@@ -37,7 +37,6 @@
 #include "vm/builtin.h"
 #include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
index d1a970f6bd247e82b0ac7d1b7f72b90348418042..36d11cd1a4d1bdf2cf44a7fe39278f56123d3aba 100644 (file)
@@ -35,7 +35,6 @@
 #include "vm/initialize.h"
 #include "vm/builtin.h"
 #include "vm/exceptions.hpp"
-#include "vm/stringlocal.h"
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
index b442f8315d430e4ee0602ea4f325ff4e39fe83c2..d8b122157b698e4ea4b458186e51342ca0c10e14 100644 (file)
 #include "vm/types.h"
 
 #include "mm/memory.h"
+
 #include "toolbox/logging.h"
+
 #include "vm/builtin.h"
 #include "vm/exceptions.hpp"
 #include "vm/resolve.h"
 #include "vm/options.h"
 #include "vm/statistics.h"
-#include "vm/stringlocal.h"
+
 #include "vm/jit/abi.h"
 #include "vm/jit/reg.h"
+
 #include "vm/jit/allocator/liveness.h"
 #include "vm/jit/allocator/lsra.h"
 
index 81b0707241243c34c1fee50fc26e9397ee8c2d42..3a7814adb48902c1d87433e32b09fb37d78c7664 100644 (file)
@@ -38,7 +38,7 @@
 #include "vm/builtin.h"
 #include "vm/exceptions.hpp"
 #include "vm/resolve.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/reg.h"
index 9d69732990e0540872f180b1c0f336ada7d474ae..e60626f3fabaff75554193c6a5b7560da4c5a62b 100644 (file)
@@ -36,7 +36,6 @@
 
 #include "vm/global.h"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 #include "vm/jit/asmpart.h"
 
 
index 91bb3bc8a4fa19bf5cfe87545192d26ed88079e1..61b14184fe9a2b4be84a189f2a71c72c8d246c00 100644 (file)
@@ -52,7 +52,6 @@ typedef struct ucontext {
 #include "threads/thread.hpp"
 
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
index c755421ac0716863b6d0fc5413ee96f366f66d3a..c9552b81ba170ea593265a4d1d758e59082196b7 100644 (file)
@@ -79,7 +79,7 @@
 
 #include "vm/builtin.h"
 #include "vm/exceptions.hpp"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
index 39a1011c84ab1f6c8586f8a8970e6181e0146cbc..8118714e9b40f6cdacb688f573fa52f2d6edc94f 100644 (file)
@@ -47,7 +47,6 @@
 #include "vm/exceptions.hpp"
 #include "vm/global.h"
 #include "vm/primitive.hpp"
-#include "vm/stringlocal.h"
 #include "vm/vm.hpp"
 
 #include "vm/jit/abi.h"
index e235f16081b3a83892252eb3ddcaa55a1b2964d5..e35e6f6a18ca1dca37200e53b182f85c3234923a 100644 (file)
@@ -33,7 +33,6 @@
 #include "vm/types.h"
 
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 #include "vm/jit/asmpart.h"
 
 
index 3af43dbb4163e0a1d7d7724561c1c456917f48db..3737b0144f1dcb3800e9338aa7a190e0e17026ab 100644 (file)
@@ -40,7 +40,6 @@
 #include "vm/builtin.h"
 #include "vm/global.h"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
index 99204eae081fefd4607573db44669aea5d5ebf11..97c362f4e081e0b8c3cfe7b7384189958926bb95 100644 (file)
@@ -39,7 +39,6 @@
 
 #include "vm/builtin.h"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
index b279afa4cc06af74d01fe910f7d1c0735581240b..bc95947bb7a16f270eab300f7733cd80d39e3759 100644 (file)
@@ -37,7 +37,6 @@
 
 #include "vm/builtin.h"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
index 1cc282a3da7989454e5f4aa1126171101d113916..a0cbdfe4a322986539cac8280a1e977b1db8546a 100644 (file)
@@ -50,7 +50,6 @@
 #include "vm/builtin.h"
 #include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
index 4719937cb49783b7063208fa8d9547236af6c717..7811ce9d0fc836f84854c8b0622df04222ec65d8 100644 (file)
@@ -44,7 +44,6 @@
 #include "vm/builtin.h"
 #include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
index ff106a4d974e43f08f59f05da0541aa22030f969..c3b609b9fbb5ab0a1bbe80d7c7a7373d0440f455 100644 (file)
@@ -37,7 +37,6 @@
 #include "threads/lock-common.h"
 
 #include "vm/builtin.h"
-#include "vm/stringlocal.h" /* XXX for gen_resolvebranch */
 
 #include "vm/jit/abi.h"
 #include "vm/jit/abi-asm.h"
index 73633f727d8e8ea62ad6514a9f10ba7b19890c59..8b54c15e80fce91954669a7666b5aa18baf97f67 100644 (file)
@@ -39,7 +39,6 @@
 
 #include "vm/global.h"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/codegen-common.h"
index d914fe659737999e499625fdeaba5704e65af5ab..2228576bc3554f43aa242e8c52abf7c4efe6a76d 100644 (file)
@@ -36,7 +36,7 @@
 #include "vm/builtin.h"
 #include "vm/resolve.h"
 #include "vm/exceptions.hpp"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vm/jit/jit.h"
 
index 7923f9e95724cc8d16a95376b502f3690c70da1a..a425d0d2005673ebc4f2f482d899bbebb5d8c5be 100644 (file)
@@ -36,7 +36,7 @@
 #include "threads/thread.hpp"
 
 #include "vm/builtin.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vm/jit/jit.h"
 #include "vm/jit/methodheader.h"
index 069ca4d8a4ca33da5e9509b7a6272072eb6ded28..4f72fd3945af39581e86c690a225f97ff8829e0e 100644 (file)
@@ -39,7 +39,7 @@
 
 #include "vm/builtin.h"
 #include "vm/exceptions.hpp"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vm/jit/code.h"
 #include "vm/jit/jit.h"
index 47c78d1fadb026f826800ace7ef5a06b85ec8081..d4cacd486f1536ab3a6f36d5bdd05f366e8686c6 100644 (file)
@@ -41,7 +41,7 @@
 #include "vm/builtin.h"
 #include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/jit.h"
index 3a69acbc33f4e01758f403345ceb1c91c409e9c7..3ad048e1425a28845e3a0e3c2f9eeaa5b31be78b 100644 (file)
@@ -46,7 +46,6 @@
 #include "vm/builtin.h"
 #include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
 #include "vm/vm.hpp"
 
 #include "vm/jit/abi.h"
index aaf2879da4db39cef053f4b08b607eb0af524327..1f026257b055ac7161263a768bb9dd0f4039b6ca 100644 (file)
@@ -40,7 +40,6 @@
 #include "vm/builtin.h"
 #include "vm/global.h"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 
 #include "vm/jit/asmpart.h"
 
index ffdc954a1f3c8713e47c948bf83cf340181a9d43..b494a73bab8b1e6b625abd807c3543cb6a1e19e8 100644 (file)
@@ -39,7 +39,6 @@
 
 #include "vm/builtin.h"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
index d3a68129d35ff5a0fa2fdf3cf206940f14490b9c..a18683ef72475c94e1b79cf88d0e784706acd892 100644 (file)
@@ -32,7 +32,7 @@
 #include "vm/jit/powerpc/netbsd/md-abi.h"
 
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
+
 #include "vm/jit/asmpart.h"
 #include "vm/jit/stacktrace.hpp"
 
index b837a26165fc3744a98987c28ddb0abfe57368b8..3a3ef06979fa264841121a5e3486cfabfffa0042 100644 (file)
@@ -47,7 +47,6 @@
 #include "vm/builtin.h"
 #include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
 #include "vm/vm.hpp"
 
 #include "vm/jit/abi.h"
index 913e18a78dc1992c5d2868a15d677612f4a839a8..52326d450ccdc8d80fe6f279fe528088d498f694 100644 (file)
@@ -42,7 +42,7 @@
 
 #include "toolbox/logging.h"
 
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
index 0fe13f6e483c7400babf1b2a2582a79819144cd1..7fec558948011f684c9f5dbdfe4243364f35a81a 100644 (file)
@@ -50,7 +50,6 @@
 #include "vm/exceptions.hpp"
 #include "vm/global.h"
 #include "vm/types.h"
-#include "vm/stringlocal.h"
 #include "vm/vm.hpp"
 
 #include "vm/jit/abi.h"
index 6cd12f0f7c2e7365c9f58598ce388020d5f50894..e0c497922525cd7f84be75328e01544f7802596a 100644 (file)
@@ -36,7 +36,7 @@
 
 #include "vm/global.h"
 #include "vm/builtin.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vm/jit/abi.h"
index ef367bb724c22dcbe199c9cb17756b551af7705e..210e6911d36b65a494e5150c68f24d61939f73c3 100644 (file)
@@ -35,7 +35,6 @@
 
 #include "mm/memory.h"
 
-#include "vm/stringlocal.h" /* XXX for gen_resolvebranch */
 #include "vm/jit/abi.h"
 #include "vm/jit/abi-asm.h"
 #include "vm/jit/asmpart.h"
index c33efe3c56c485362231ae4be3b1de33d1fc4a3d..e1cdfdb9f08de767d5931942ad77fa128b0711a5 100644 (file)
@@ -35,7 +35,6 @@
 #include "vm/jit/sparc64/md-abi.h"
 
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/stacktrace.hpp"
index e9f62e7c72fd20bac5f3ea718d31f01e78dd41e1..ab2b30708acd7ec9b540e205b177e61767d82f33 100644 (file)
@@ -32,8 +32,6 @@
 
 #include "vm/jit/sparc64/md-abi.h"
 
-#include "vm/stringlocal.h"
-
 #include "vm/jit/asmpart.h"
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/jit.h"
index 10fd0a6749966b7a314520e26e8d5dd04d0def0f..7c4c802a84d1c7bc3a27784cdc854854300ba231 100644 (file)
@@ -38,7 +38,6 @@
 #include "vm/jit/sparc64/md-abi.h"
 
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/stacktrace.hpp"
index 10c7f863171e8ee5d892e4bdba94ae233d05a910..d06bac772c149daed7e4a874687e6c85b5961ec6 100644 (file)
@@ -42,7 +42,7 @@
 #include "vm/global.h"
 #include "vm/builtin.h"
 #include "vm/exceptions.hpp"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/types.h"
 
 #include "vm/jit/abi.h"
index 32964fcd30aa4f585679441af7c6f120110cc785..f1ac6c92e816d27ec7b0bf8cf9a127226ae9286d 100644 (file)
@@ -59,7 +59,7 @@
 #include "vm/builtin.h"
 #include "vm/cycles-stats.h"
 #include "vm/exceptions.hpp"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
index 79faed007bdb20a6f0dd8562f3be5501e119445c..b2c87770219b7b48bc377367c7890246a540793a 100644 (file)
@@ -46,7 +46,7 @@ extern "C" {
 #include "toolbox/logging.h"
 
 #include "vm/global.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/jit/argument.h"
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/trace.hpp"
index f2f2a5f1f1fb666b996297baf7002dc59de18d0d..b66112e9f9e636914e7152b33fbfb7c308ae4bcb 100644 (file)
@@ -49,7 +49,7 @@
 #include "vm/exceptions.hpp"
 #include "vm/global.h"
 #include "vm/primitive.hpp"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vm/jit/abi.h"
index 647baf1914f6794d7c98504964d2ac670970a134..c0513bee1a4079afaefcfb357402435f0bb68f1a 100644 (file)
@@ -36,7 +36,7 @@
 #include "native/include/java_lang_String.h"
 
 #include "vm/package.hpp"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #include "vmcore/options.h"
 #include "vmcore/utf8.h"
index 5288ea1387495ec5a3cf561b6ec932a6cae022ca..b5d9760a29666a229e84d48d064b8388760ee1aa 100644 (file)
@@ -46,7 +46,7 @@
 #include "toolbox/util.h"
 
 #include "vm/properties.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
diff --git a/src/vm/string.c b/src/vm/string.c
deleted file mode 100644 (file)
index c75fbf2..0000000
+++ /dev/null
@@ -1,806 +0,0 @@
-/* src/vm/string.c - java.lang.String related functions
-
-   Copyright (C) 1996-2005, 2006, 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   This file is part of CACAO.
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2, or (at
-   your option) any later version.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-
-#include "vmcore/system.h"
-
-#include "vm/types.h"
-
-#include "vm/global.h"
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-
-#include "native/include/java_lang_String.h"
-
-#include "threads/lock-common.h"
-
-#include "vm/array.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.hpp"
-#include "vm/primitive.hpp"
-#include "vm/stringlocal.h"
-#include "vm/vm.hpp"
-
-#include "vmcore/globals.hpp"
-#include "vmcore/options.h"
-#include "vmcore/statistics.h"
-#include "vmcore/utf8.h"
-
-
-/* global variables ***********************************************************/
-
-/* hashsize must be power of 2 */
-
-#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
-
-
-/* XXX preliminary typedef, will be removed once string.c and utf8.c are
-   unified. */
-
-#if defined(ENABLE_HANDLES)
-typedef heap_java_lang_String heapstring_t;
-#else
-typedef java_lang_String heapstring_t;
-#endif
-
-
-/* string_init *****************************************************************
-
-   Initialize the string hashtable lock.
-
-*******************************************************************************/
-
-bool string_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("string_init");
-
-       /* create string (javastring) hashtable */
-
-       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
-
-       /* everything's ok */
-
-       return true;
-}
-
-
-/* stringtable_update **********************************************************
-
-   Traverses the javastring hashtable and sets the vftbl-entries of
-   javastrings which were temporarily set to NULL, because
-   java.lang.Object was not yet loaded.
-
-*******************************************************************************/
-void stringtable_update(void)
-{
-       heapstring_t     *js;
-       java_chararray_t *a;
-       literalstring    *s;       /* hashtable entry */
-       int i;
-
-       for (i = 0; i < hashtable_string.size; i++) {
-               s = hashtable_string.ptr[i];
-               if (s) {
-                       while (s) {
-                               js = (heapstring_t *) s->string;
-                               
-                               if ((js == NULL) || (js->value == NULL)) {
-                                       /* error in hashtable found */
-
-                                       vm_abort("stringtable_update: invalid literalstring in hashtable");
-                               }
-
-                               a = js->value;
-
-                               if (!js->header.vftbl) 
-                                       /* vftbl of javastring is NULL */ 
-                                       js->header.vftbl = class_java_lang_String->vftbl;
-
-                               if (!a->header.objheader.vftbl) 
-                                       /* vftbl of character-array is NULL */ 
-                                       a->header.objheader.vftbl =
-                                               Primitive_get_arrayclass_by_type(ARRAYTYPE_CHAR)->vftbl;
-
-                               /* follow link in external hash chain */
-                               s = s->hashlink;
-                       }       
-               }               
-       }
-}
-
-
-/* javastring_new_from_utf_buffer **********************************************
-
-   Create a new object of type java/lang/String with the text from
-   the specified utf8 buffer.
-
-   IN:
-      buffer.......points to first char in the buffer
-         blength......number of bytes to read from the buffer
-
-   RETURN VALUE:
-      the java.lang.String object, or
-      NULL if an exception has been thrown
-
-*******************************************************************************/
-
-static java_handle_t *javastring_new_from_utf_buffer(const char *buffer,
-                                                                                                                u4 blength)
-{
-       const char *utf_ptr;            /* current utf character in utf string    */
-       u4 utflength;                   /* length of utf-string if uncompressed   */
-       java_handle_t     *o;
-       java_lang_String  *s;           /* result-string                          */
-       java_handle_chararray_t *a;
-       u4 i;
-
-       assert(buffer);
-
-       utflength = utf_get_number_of_u2s_for_buffer(buffer,blength);
-
-       o = builtin_new(class_java_lang_String);
-       a = builtin_newarray_char(utflength);
-
-       /* javastring or character-array could not be created */
-
-       if ((o == NULL) || (a == NULL))
-               return NULL;
-
-       /* decompress utf-string */
-
-       utf_ptr = buffer;
-
-       for (i = 0; i < utflength; i++)
-               LLNI_array_direct(a, i) = utf_nextu2((char **) &utf_ptr);
-       
-       /* set fields of the javastring-object */
-
-       s = (java_lang_String *) o;
-
-       LLNI_field_set_ref(s, value , a);
-       LLNI_field_set_val(s, offset, 0);
-       LLNI_field_set_val(s, count , utflength);
-
-       return o;
-}
-
-
-/* javastring_safe_new_from_utf8 ***********************************************
-
-   Create a new object of type java/lang/String with the text from
-   the specified UTF-8 string. This function is safe for invalid UTF-8.
-   (Invalid characters will be replaced by U+fffd.)
-
-   IN:
-      text.........the UTF-8 string, zero-terminated.
-
-   RETURN VALUE:
-      the java.lang.String object, or
-      NULL if an exception has been thrown
-
-*******************************************************************************/
-
-java_handle_t *javastring_safe_new_from_utf8(const char *text)
-{
-       java_handle_t           *o;
-       java_handle_chararray_t *a;
-       java_lang_String        *s;
-       s4 nbytes;
-       s4 len;
-
-       if (text == NULL)
-               return NULL;
-
-       /* Get number of bytes. We need this to completely emulate the messy */
-       /* behaviour of the RI. :(                                           */
-
-       nbytes = strlen(text);
-
-       /* calculate number of Java characters */
-
-       len = utf8_safe_number_of_u2s(text, nbytes);
-
-       /* allocate the String object and the char array */
-
-       o = builtin_new(class_java_lang_String);
-       a = builtin_newarray_char(len);
-
-       /* javastring or character-array could not be created? */
-
-       if ((o == NULL) || (a == NULL))
-               return NULL;
-
-       /* decompress UTF-8 string */
-
-       utf8_safe_convert_to_u2s(text, nbytes, LLNI_array_data(a));
-
-       /* set fields of the String object */
-
-       s = (java_lang_String *) o;
-
-       LLNI_field_set_ref(s, value , a);
-       LLNI_field_set_val(s, offset, 0);
-       LLNI_field_set_val(s, count , len);
-
-       return o;
-}
-
-
-/* javastring_new_from_utf_string **********************************************
-
-   Create a new object of type java/lang/String with the text from
-   the specified zero-terminated utf8 string.
-
-   IN:
-      buffer.......points to first char in the buffer
-         blength......number of bytes to read from the buffer
-
-   RETURN VALUE:
-      the java.lang.String object, or
-      NULL if an exception has been thrown
-
-*******************************************************************************/
-
-java_handle_t *javastring_new_from_utf_string(const char *utfstr)
-{
-       assert(utfstr);
-
-       return javastring_new_from_utf_buffer(utfstr, strlen(utfstr));
-}
-
-
-/* javastring_new **************************************************************
-
-   creates a new object of type java/lang/String with the text of 
-   the specified utf8-string
-
-   return: pointer to the string or NULL if memory is exhausted.       
-
-*******************************************************************************/
-
-java_handle_t *javastring_new(utf *u)
-{
-       char *utf_ptr;                  /* current utf character in utf string    */
-       u4 utflength;                   /* length of utf-string if uncompressed   */
-       java_handle_t           *o;
-       java_handle_chararray_t *a;
-       java_lang_String        *s;
-       s4 i;
-
-       if (u == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       utf_ptr = u->text;
-       utflength = utf_get_number_of_u2s(u);
-
-       o = builtin_new(class_java_lang_String);
-       a = builtin_newarray_char(utflength);
-
-       /* javastring or character-array could not be created */
-
-       if ((o == NULL) || (a == NULL))
-               return NULL;
-
-       /* decompress utf-string */
-
-       for (i = 0; i < utflength; i++)
-               LLNI_array_direct(a, i) = utf_nextu2(&utf_ptr);
-       
-       /* set fields of the javastring-object */
-
-       s = (java_lang_String *) o;
-
-       LLNI_field_set_ref(s, value , a);
-       LLNI_field_set_val(s, offset, 0);
-       LLNI_field_set_val(s, count , utflength);
-
-       return o;
-}
-
-
-/* javastring_new_slash_to_dot *************************************************
-
-   creates a new object of type java/lang/String with the text of 
-   the specified utf8-string with slashes changed to dots
-
-   return: pointer to the string or NULL if memory is exhausted.       
-
-*******************************************************************************/
-
-java_handle_t *javastring_new_slash_to_dot(utf *u)
-{
-       char *utf_ptr;                  /* current utf character in utf string    */
-       u4 utflength;                   /* length of utf-string if uncompressed   */
-       java_handle_t           *o;
-       java_handle_chararray_t *a;
-       java_lang_String        *s;
-       s4 i;
-       u2 ch;
-
-       if (u == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       utf_ptr = u->text;
-       utflength = utf_get_number_of_u2s(u);
-
-       o = builtin_new(class_java_lang_String);
-       a = builtin_newarray_char(utflength);
-
-       /* javastring or character-array could not be created */
-       if ((o == NULL) || (a == NULL))
-               return NULL;
-
-       /* decompress utf-string */
-
-       for (i = 0; i < utflength; i++) {
-               ch = utf_nextu2(&utf_ptr);
-               if (ch == '/')
-                       ch = '.';
-               LLNI_array_direct(a, i) = ch;
-       }
-       
-       /* set fields of the javastring-object */
-
-       s = (java_lang_String *) o;
-
-       LLNI_field_set_ref(s, value , a);
-       LLNI_field_set_val(s, offset, 0);
-       LLNI_field_set_val(s, count , utflength);
-
-       return o;
-}
-
-
-/* javastring_new_from_ascii ***************************************************
-
-   creates a new java/lang/String object which contains the given ASCII
-   C-string converted to UTF-16.
-
-   IN:
-      text.........string of ASCII characters
-
-   RETURN VALUE:
-      the java.lang.String object, or 
-      NULL if an exception has been thrown.
-
-*******************************************************************************/
-
-java_handle_t *javastring_new_from_ascii(const char *text)
-{
-       s4 i;
-       s4 len;                             /* length of the string               */
-       java_handle_t           *o;
-       java_lang_String        *s;
-       java_handle_chararray_t *a;
-
-       if (text == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       len = strlen(text);
-
-       o = builtin_new(class_java_lang_String);
-       a = builtin_newarray_char(len);
-
-       /* javastring or character-array could not be created */
-
-       if ((o == NULL) || (a == NULL))
-               return NULL;
-
-       /* copy text */
-
-       for (i = 0; i < len; i++)
-               LLNI_array_direct(a, i) = text[i];
-       
-       /* set fields of the javastring-object */
-
-       s = (java_lang_String *) o;
-
-       LLNI_field_set_ref(s, value , a);
-       LLNI_field_set_val(s, offset, 0);
-       LLNI_field_set_val(s, count , len);
-
-       return o;
-}
-
-
-/* javastring_tochar ***********************************************************
-
-   converts a Java string into a C string.
-       
-   return: pointer to C string
-       
-   Caution: calling method MUST release the allocated memory!
-       
-*******************************************************************************/
-
-char *javastring_tochar(java_handle_t *so) 
-{
-       java_lang_String        *s = (java_lang_String *) so;
-       java_handle_chararray_t *a;
-       int32_t                  count;
-       int32_t                  offset;
-       char *buf;
-       s4 i;
-       
-       if (!s)
-               return "";
-
-       LLNI_field_get_ref(s, value, a);
-
-       if (!a)
-               return "";
-
-       LLNI_field_get_val(s, count, count);
-       LLNI_field_get_val(s, offset, offset);
-
-       buf = MNEW(char, count + 1);
-
-       for (i = 0; i < count; i++)
-               buf[i] = LLNI_array_direct(a, offset + i);
-
-       buf[i] = '\0';
-
-       return buf;
-}
-
-
-/* javastring_toutf ************************************************************
-
-   Make utf symbol from javastring.
-
-*******************************************************************************/
-
-utf *javastring_toutf(java_handle_t *string, bool isclassname)
-{
-       java_lang_String        *s;
-       java_handle_chararray_t *value;
-       int32_t                  count;
-       int32_t                  offset;
-
-       s = (java_lang_String *) string;
-
-       if (s == NULL)
-               return utf_null;
-
-       LLNI_field_get_ref(s, value, value);
-
-       if (value == NULL)
-               return utf_null;
-
-       LLNI_field_get_val(s, count, count);
-       LLNI_field_get_val(s, offset, offset);
-
-       return utf_new_u2(LLNI_array_data(value) + offset, count, isclassname);
-}
-
-
-/* literalstring_u2 ************************************************************
-
-   Searches for the literalstring with the specified u2-array in the
-   string hashtable, if there is no such string a new one is created.
-
-   If copymode is true a copy of the u2-array is made.
-
-*******************************************************************************/
-
-static java_object_t *literalstring_u2(java_chararray_t *a, u4 length,
-                                                                          u4 offset, bool copymode)
-{
-    literalstring    *s;                /* hashtable element                  */
-    heapstring_t     *js;               /* u2-array wrapped in javastring     */
-    java_chararray_t *ca;               /* copy of u2-array                   */
-    u4                key;
-    u4                slot;
-    u2                i;
-
-       LOCK_MONITOR_ENTER(lock_hashtable_string);
-
-    /* find location in hashtable */
-
-    key  = unicode_hashkey(a->data + offset, length);
-    slot = key & (hashtable_string.size - 1);
-    s    = hashtable_string.ptr[slot];
-
-    while (s) {
-               js = (heapstring_t *) s->string;
-
-               if (length == js->count) {
-                       /* compare text */
-
-                       for (i = 0; i < length; i++)
-                               if (a->data[offset + i] != js->value->data[i])
-                                       goto nomatch;
-
-                       /* string already in hashtable, free memory */
-
-                       if (!copymode)
-                               mem_free(a, sizeof(java_chararray_t) + sizeof(u2) * (length - 1) + 10);
-
-                       LOCK_MONITOR_EXIT(lock_hashtable_string);
-
-                       return (java_object_t *) js;
-               }
-
-       nomatch:
-               /* follow link in external hash chain */
-               s = s->hashlink;
-    }
-
-    if (copymode) {
-               /* create copy of u2-array for new javastring */
-               u4 arraysize = sizeof(java_chararray_t) + sizeof(u2) * (length - 1) + 10;
-               ca = mem_alloc(arraysize);
-/*             memcpy(ca, a, arraysize); */
-               memcpy(&(ca->header), &(a->header), sizeof(java_array_t));
-               memcpy(&(ca->data), &(a->data) + offset, sizeof(u2) * (length - 1) + 10);
-
-    } else {
-               ca = a;
-       }
-
-    /* location in hashtable found, complete arrayheader */
-
-    ca->header.objheader.vftbl =
-               Primitive_get_arrayclass_by_type(ARRAYTYPE_CHAR)->vftbl;
-    ca->header.size            = length;
-
-       assert(class_java_lang_String);
-       assert(class_java_lang_String->state & CLASS_LOADED);
-
-       /* create new javastring */
-
-       js = NEW(heapstring_t);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_string += sizeof(heapstring_t);
-#endif
-
-#if defined(ENABLE_THREADS)
-       lock_init_object_lock(&js->header);
-#endif
-
-       js->header.vftbl = class_java_lang_String->vftbl;
-       js->value  = ca;
-       js->offset = 0;
-       js->count  = length;
-
-       /* create new literalstring */
-
-       s = NEW(literalstring);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_string += sizeof(literalstring);
-#endif
-
-       s->hashlink = hashtable_string.ptr[slot];
-       s->string   = (java_object_t *) js;
-       hashtable_string.ptr[slot] = s;
-
-       /* update number of hashtable entries */
-
-       hashtable_string.entries++;
-
-       /* reorganization of hashtable */       
-
-       if (hashtable_string.entries > (hashtable_string.size * 2)) {
-               /* reorganization of hashtable, average length of the external
-                  chains is approx. 2 */
-
-               u4             i;
-               literalstring *s;
-               literalstring *nexts;
-               heapstring_t  *tmpjs;
-               hashtable      newhash;                          /* the new hashtable */
-      
-               /* create new hashtable, double the size */
-
-               hashtable_create(&newhash, hashtable_string.size * 2);
-               newhash.entries = hashtable_string.entries;
-      
-               /* transfer elements to new hashtable */
-
-               for (i = 0; i < hashtable_string.size; i++) {
-                       s = hashtable_string.ptr[i];
-
-                       while (s) {
-                               nexts = s->hashlink;
-                               tmpjs = (heapstring_t *) s->string;
-                               slot  = unicode_hashkey(tmpjs->value->data, tmpjs->count) & (newhash.size - 1);
-         
-                               s->hashlink = newhash.ptr[slot];
-                               newhash.ptr[slot] = s;
-       
-                               /* follow link in external hash chain */
-                               s = nexts;
-                       }
-               }
-       
-               /* dispose old table */
-
-               MFREE(hashtable_string.ptr, void*, hashtable_string.size);
-               hashtable_string = newhash;
-       }
-
-       LOCK_MONITOR_EXIT(lock_hashtable_string);
-
-       return (java_object_t *) js;
-}
-
-
-/* literalstring_new ***********************************************************
-
-   Creates a new literalstring with the text of the utf-symbol and inserts
-   it into the string hashtable.
-
-*******************************************************************************/
-
-java_object_t *literalstring_new(utf *u)
-{
-    char             *utf_ptr;       /* pointer to current unicode character  */
-                                        /* utf string                            */
-    u4                utflength;     /* length of utf-string if uncompressed  */
-    java_chararray_t *a;             /* u2-array constructed from utf string  */
-    u4                i;
-
-       utf_ptr = u->text;
-       utflength = utf_get_number_of_u2s(u);
-
-    /* allocate memory */ 
-    a = mem_alloc(sizeof(java_chararray_t) + sizeof(u2) * (utflength - 1) + 10);
-
-    /* convert utf-string to u2-array */
-    for (i = 0; i < utflength; i++)
-               a->data[i] = utf_nextu2(&utf_ptr);
-
-    return literalstring_u2(a, utflength, 0, false);
-}
-
-
-/* literalstring_free **********************************************************
-
-   Removes a literalstring from memory.
-
-*******************************************************************************/
-
-#if 0
-/* TWISTI This one is currently not used. */
-
-static void literalstring_free(java_object_t* string)
-{
-       heapstring_t     *s;
-       java_chararray_t *a;
-
-       s = (heapstring_t *) string;
-       a = s->value;
-
-       /* dispose memory of java.lang.String object */
-       FREE(s, heapstring_t);
-
-       /* dispose memory of java-characterarray */
-       FREE(a, sizeof(java_chararray_t) + sizeof(u2) * (a->header.size - 1)); /* +10 ?? */
-}
-#endif
-
-
-/* javastring_intern ***********************************************************
-
-   Intern the given Java string.
-
-   XXX NOTE: Literal Strings are direct references since they are not placed
-   onto the GC-Heap. That's why this function looks so "different".
-
-*******************************************************************************/
-
-java_handle_t *javastring_intern(java_handle_t *s)
-{
-       java_lang_String *so;
-       java_chararray_t *value;
-       int32_t           count;
-       int32_t           offset;
-/*     java_lang_String *o; */
-       java_object_t    *o; /* XXX see note above */
-
-       so = (java_lang_String *) s;
-
-       value  = LLNI_field_direct(so, value); /* XXX see note above */
-       LLNI_field_get_val(so, count, count);
-       LLNI_field_get_val(so, offset, offset);
-
-       o = literalstring_u2(value, count, offset, true);
-
-       return LLNI_WRAP(o); /* XXX see note above */
-}
-
-
-/* javastring_fprint ***********************************************************
-
-   Print the given Java string to the given stream.
-
-*******************************************************************************/
-
-void javastring_fprint(java_handle_t *s, FILE *stream)
-{
-       java_lang_String        *so;
-       java_handle_chararray_t *value;
-       int32_t                  count;
-       int32_t                  offset;
-       uint16_t                 c;
-       int                      i;
-
-       so = (java_lang_String *) s;
-
-       LLNI_field_get_ref(so, value, value);
-       LLNI_field_get_val(so, count, count);
-       LLNI_field_get_val(so, offset, offset);
-
-       for (i = offset; i < offset + count; i++) {
-               c = LLNI_array_direct(value, i);
-               fputc(c, stream);
-       }
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
diff --git a/src/vm/string.cpp b/src/vm/string.cpp
new file mode 100644 (file)
index 0000000..f40ee0f
--- /dev/null
@@ -0,0 +1,802 @@
+/* src/vm/string.cpp - java.lang.String related functions
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+
+#include "vmcore/system.h"
+
+#include "vm/types.h"
+
+#include "vm/global.h"
+
+#include "mm/memory.h"
+
+#include "native/jni.h"
+#include "native/llni.h"
+
+#include "native/include/java_lang_String.h"
+
+#include "threads/lock-common.h"
+
+#include "vm/array.h"
+#include "vm/builtin.h"
+#include "vm/exceptions.hpp"
+#include "vm/primitive.hpp"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
+
+#include "vmcore/globals.hpp"
+#include "vmcore/options.h"
+#include "vmcore/statistics.h"
+#include "vmcore/utf8.h"
+
+
+/* global variables ***********************************************************/
+
+/* hashsize must be power of 2 */
+
+#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
+
+
+/* XXX preliminary typedef, will be removed once string.c and utf8.c are
+   unified. */
+
+#if defined(ENABLE_HANDLES)
+typedef heap_java_lang_String heapstring_t;
+#else
+typedef java_lang_String heapstring_t;
+#endif
+
+
+/* string_init *****************************************************************
+
+   Initialize the string hashtable lock.
+
+*******************************************************************************/
+
+bool string_init(void)
+{
+       TRACESUBSYSTEMINITIALIZATION("string_init");
+
+       /* create string (javastring) hashtable */
+
+       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
+
+       /* everything's ok */
+
+       return true;
+}
+
+
+/* stringtable_update **********************************************************
+
+   Traverses the javastring hashtable and sets the vftbl-entries of
+   javastrings which were temporarily set to NULL, because
+   java.lang.Object was not yet loaded.
+
+*******************************************************************************/
+void stringtable_update(void)
+{
+       heapstring_t     *js;
+       java_chararray_t *a;
+       literalstring    *s;       /* hashtable entry */
+
+       for (unsigned int i = 0; i < hashtable_string.size; i++) {
+               s = (literalstring*) hashtable_string.ptr[i];
+
+               if (s) {
+                       while (s) {
+                               js = (heapstring_t *) s->string;
+                               
+                               if ((js == NULL) || (js->value == NULL)) {
+                                       /* error in hashtable found */
+
+                                       vm_abort("stringtable_update: invalid literalstring in hashtable");
+                               }
+
+                               a = js->value;
+
+                               if (!js->header.vftbl) 
+                                       /* vftbl of javastring is NULL */ 
+                                       js->header.vftbl = class_java_lang_String->vftbl;
+
+                               if (!a->header.objheader.vftbl) 
+                                       /* vftbl of character-array is NULL */ 
+                                       a->header.objheader.vftbl = Primitive::get_arrayclass_by_type(ARRAYTYPE_CHAR)->vftbl;
+
+                               /* follow link in external hash chain */
+                               s = s->hashlink;
+                       }       
+               }               
+       }
+}
+
+
+/* javastring_new_from_utf_buffer **********************************************
+
+   Create a new object of type java/lang/String with the text from
+   the specified utf8 buffer.
+
+   IN:
+      buffer.......points to first char in the buffer
+         blength......number of bytes to read from the buffer
+
+   RETURN VALUE:
+      the java.lang.String object, or
+      NULL if an exception has been thrown
+
+*******************************************************************************/
+
+static java_handle_t *javastring_new_from_utf_buffer(const char *buffer,
+                                                                                                                u4 blength)
+{
+       const char *utf_ptr;            /* current utf character in utf string    */
+       u4 utflength;                   /* length of utf-string if uncompressed   */
+       java_handle_t     *o;
+       java_lang_String  *s;           /* result-string                          */
+       java_handle_chararray_t *a;
+       u4 i;
+
+       assert(buffer);
+
+       utflength = utf_get_number_of_u2s_for_buffer(buffer,blength);
+
+       o = builtin_new(class_java_lang_String);
+       a = builtin_newarray_char(utflength);
+
+       /* javastring or character-array could not be created */
+
+       if ((o == NULL) || (a == NULL))
+               return NULL;
+
+       /* decompress utf-string */
+
+       utf_ptr = buffer;
+
+       for (i = 0; i < utflength; i++)
+               LLNI_array_direct(a, i) = utf_nextu2((char **) &utf_ptr);
+       
+       /* set fields of the javastring-object */
+
+       s = (java_lang_String *) o;
+
+       LLNI_field_set_ref(s, value , a);
+       LLNI_field_set_val(s, offset, 0);
+       LLNI_field_set_val(s, count , utflength);
+
+       return o;
+}
+
+
+/* javastring_safe_new_from_utf8 ***********************************************
+
+   Create a new object of type java/lang/String with the text from
+   the specified UTF-8 string. This function is safe for invalid UTF-8.
+   (Invalid characters will be replaced by U+fffd.)
+
+   IN:
+      text.........the UTF-8 string, zero-terminated.
+
+   RETURN VALUE:
+      the java.lang.String object, or
+      NULL if an exception has been thrown
+
+*******************************************************************************/
+
+java_handle_t *javastring_safe_new_from_utf8(const char *text)
+{
+       java_handle_t           *o;
+       java_handle_chararray_t *a;
+       java_lang_String        *s;
+       s4 nbytes;
+       s4 len;
+
+       if (text == NULL)
+               return NULL;
+
+       /* Get number of bytes. We need this to completely emulate the messy */
+       /* behaviour of the RI. :(                                           */
+
+       nbytes = strlen(text);
+
+       /* calculate number of Java characters */
+
+       len = utf8_safe_number_of_u2s(text, nbytes);
+
+       /* allocate the String object and the char array */
+
+       o = builtin_new(class_java_lang_String);
+       a = builtin_newarray_char(len);
+
+       /* javastring or character-array could not be created? */
+
+       if ((o == NULL) || (a == NULL))
+               return NULL;
+
+       /* decompress UTF-8 string */
+
+       utf8_safe_convert_to_u2s(text, nbytes, LLNI_array_data(a));
+
+       /* set fields of the String object */
+
+       s = (java_lang_String *) o;
+
+       LLNI_field_set_ref(s, value , a);
+       LLNI_field_set_val(s, offset, 0);
+       LLNI_field_set_val(s, count , len);
+
+       return o;
+}
+
+
+/* javastring_new_from_utf_string **********************************************
+
+   Create a new object of type java/lang/String with the text from
+   the specified zero-terminated utf8 string.
+
+   IN:
+      buffer.......points to first char in the buffer
+         blength......number of bytes to read from the buffer
+
+   RETURN VALUE:
+      the java.lang.String object, or
+      NULL if an exception has been thrown
+
+*******************************************************************************/
+
+java_handle_t *javastring_new_from_utf_string(const char *utfstr)
+{
+       assert(utfstr);
+
+       return javastring_new_from_utf_buffer(utfstr, strlen(utfstr));
+}
+
+
+/* javastring_new **************************************************************
+
+   creates a new object of type java/lang/String with the text of 
+   the specified utf8-string
+
+   return: pointer to the string or NULL if memory is exhausted.       
+
+*******************************************************************************/
+
+java_handle_t *javastring_new(utf *u)
+{
+       char *utf_ptr;                  /* current utf character in utf string    */
+       int32_t utflength;                   /* length of utf-string if uncompressed   */
+       java_handle_t           *o;
+       java_handle_chararray_t *a;
+       java_lang_String        *s;
+
+       if (u == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       utf_ptr = u->text;
+       utflength = utf_get_number_of_u2s(u);
+
+       o = builtin_new(class_java_lang_String);
+       a = builtin_newarray_char(utflength);
+
+       /* javastring or character-array could not be created */
+
+       if ((o == NULL) || (a == NULL))
+               return NULL;
+
+       /* decompress utf-string */
+
+       for (int32_t i = 0; i < utflength; i++)
+               LLNI_array_direct(a, i) = utf_nextu2(&utf_ptr);
+       
+       /* set fields of the javastring-object */
+
+       s = (java_lang_String *) o;
+
+       LLNI_field_set_ref(s, value , a);
+       LLNI_field_set_val(s, offset, 0);
+       LLNI_field_set_val(s, count , utflength);
+
+       return o;
+}
+
+
+/* javastring_new_slash_to_dot *************************************************
+
+   creates a new object of type java/lang/String with the text of 
+   the specified utf8-string with slashes changed to dots
+
+   return: pointer to the string or NULL if memory is exhausted.       
+
+*******************************************************************************/
+
+java_handle_t *javastring_new_slash_to_dot(utf *u)
+{
+       char *utf_ptr;                  /* current utf character in utf string    */
+       int32_t utflength;                   /* length of utf-string if uncompressed   */
+       java_handle_t           *o;
+       java_handle_chararray_t *a;
+       java_lang_String        *s;
+       u2 ch;
+
+       if (u == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       utf_ptr = u->text;
+       utflength = utf_get_number_of_u2s(u);
+
+       o = builtin_new(class_java_lang_String);
+       a = builtin_newarray_char(utflength);
+
+       /* javastring or character-array could not be created */
+       if ((o == NULL) || (a == NULL))
+               return NULL;
+
+       /* decompress utf-string */
+
+       for (int32_t i = 0; i < utflength; i++) {
+               ch = utf_nextu2(&utf_ptr);
+               if (ch == '/')
+                       ch = '.';
+               LLNI_array_direct(a, i) = ch;
+       }
+       
+       /* set fields of the javastring-object */
+
+       s = (java_lang_String *) o;
+
+       LLNI_field_set_ref(s, value , a);
+       LLNI_field_set_val(s, offset, 0);
+       LLNI_field_set_val(s, count , utflength);
+
+       return o;
+}
+
+
+/* javastring_new_from_ascii ***************************************************
+
+   creates a new java/lang/String object which contains the given ASCII
+   C-string converted to UTF-16.
+
+   IN:
+      text.........string of ASCII characters
+
+   RETURN VALUE:
+      the java.lang.String object, or 
+      NULL if an exception has been thrown.
+
+*******************************************************************************/
+
+java_handle_t *javastring_new_from_ascii(const char *text)
+{
+       s4 i;
+       s4 len;                             /* length of the string               */
+       java_handle_t           *o;
+       java_lang_String        *s;
+       java_handle_chararray_t *a;
+
+       if (text == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       len = strlen(text);
+
+       o = builtin_new(class_java_lang_String);
+       a = builtin_newarray_char(len);
+
+       /* javastring or character-array could not be created */
+
+       if ((o == NULL) || (a == NULL))
+               return NULL;
+
+       /* copy text */
+
+       for (i = 0; i < len; i++)
+               LLNI_array_direct(a, i) = text[i];
+       
+       /* set fields of the javastring-object */
+
+       s = (java_lang_String *) o;
+
+       LLNI_field_set_ref(s, value , a);
+       LLNI_field_set_val(s, offset, 0);
+       LLNI_field_set_val(s, count , len);
+
+       return o;
+}
+
+
+/* javastring_tochar ***********************************************************
+
+   converts a Java string into a C string.
+       
+   return: pointer to C string
+       
+   Caution: calling method MUST release the allocated memory!
+       
+*******************************************************************************/
+
+char *javastring_tochar(java_handle_t *so) 
+{
+       java_lang_String        *s = (java_lang_String *) so;
+       java_handle_chararray_t *a;
+       int32_t                  count;
+       int32_t                  offset;
+       char *buf;
+       s4 i;
+       
+       if (!s)
+               return (char*) "";
+
+       LLNI_field_get_ref(s, value, a);
+
+       if (!a)
+               return (char*) "";
+
+       LLNI_field_get_val(s, count, count);
+       LLNI_field_get_val(s, offset, offset);
+
+       buf = MNEW(char, count + 1);
+
+       for (i = 0; i < count; i++)
+               buf[i] = LLNI_array_direct(a, offset + i);
+
+       buf[i] = '\0';
+
+       return buf;
+}
+
+
+/* javastring_toutf ************************************************************
+
+   Make utf symbol from javastring.
+
+*******************************************************************************/
+
+utf *javastring_toutf(java_handle_t *string, bool isclassname)
+{
+       java_lang_String        *s;
+       java_handle_chararray_t *value;
+       int32_t                  count;
+       int32_t                  offset;
+
+       s = (java_lang_String *) string;
+
+       if (s == NULL)
+               return utf_null;
+
+       LLNI_field_get_ref(s, value, value);
+
+       if (value == NULL)
+               return utf_null;
+
+       LLNI_field_get_val(s, count, count);
+       LLNI_field_get_val(s, offset, offset);
+
+       return utf_new_u2(LLNI_array_data(value) + offset, count, isclassname);
+}
+
+
+/* literalstring_u2 ************************************************************
+
+   Searches for the literalstring with the specified u2-array in the
+   string hashtable, if there is no such string a new one is created.
+
+   If copymode is true a copy of the u2-array is made.
+
+*******************************************************************************/
+
+static java_object_t *literalstring_u2(java_chararray_t *a, int32_t length,
+                                                                          u4 offset, bool copymode)
+{
+    literalstring    *s;                /* hashtable element                  */
+    heapstring_t     *js;               /* u2-array wrapped in javastring     */
+    java_chararray_t *ca;               /* copy of u2-array                   */
+    u4                key;
+    u4                slot;
+    u2                i;
+
+       LOCK_MONITOR_ENTER(lock_hashtable_string);
+
+    /* find location in hashtable */
+
+    key  = unicode_hashkey(a->data + offset, length);
+    slot = key & (hashtable_string.size - 1);
+    s    = (literalstring*) hashtable_string.ptr[slot];
+
+    while (s) {
+               js = (heapstring_t *) s->string;
+
+               if (length == js->count) {
+                       /* compare text */
+
+                       for (i = 0; i < length; i++)
+                               if (a->data[offset + i] != js->value->data[i])
+                                       goto nomatch;
+
+                       /* string already in hashtable, free memory */
+
+                       if (!copymode)
+                               mem_free(a, sizeof(java_chararray_t) + sizeof(u2) * (length - 1) + 10);
+
+                       LOCK_MONITOR_EXIT(lock_hashtable_string);
+
+                       return (java_object_t *) js;
+               }
+
+       nomatch:
+               /* follow link in external hash chain */
+               s = s->hashlink;
+    }
+
+    if (copymode) {
+               /* create copy of u2-array for new javastring */
+               u4 arraysize = sizeof(java_chararray_t) + sizeof(u2) * (length - 1) + 10;
+               ca = (java_chararray_t*) mem_alloc(arraysize);
+/*             memcpy(ca, a, arraysize); */
+               memcpy(&(ca->header), &(a->header), sizeof(java_array_t));
+               memcpy(&(ca->data), &(a->data) + offset, sizeof(u2) * (length - 1) + 10);
+
+    } else {
+               ca = a;
+       }
+
+    /* location in hashtable found, complete arrayheader */
+
+    ca->header.objheader.vftbl = Primitive::get_arrayclass_by_type(ARRAYTYPE_CHAR)->vftbl;
+    ca->header.size            = length;
+
+       assert(class_java_lang_String);
+       assert(class_java_lang_String->state & CLASS_LOADED);
+
+       /* create new javastring */
+
+       js = NEW(heapstring_t);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_string += sizeof(heapstring_t);
+#endif
+
+#if defined(ENABLE_THREADS)
+       lock_init_object_lock(&js->header);
+#endif
+
+       js->header.vftbl = class_java_lang_String->vftbl;
+       js->value  = ca;
+       js->offset = 0;
+       js->count  = length;
+
+       /* create new literalstring */
+
+       s = NEW(literalstring);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_string += sizeof(literalstring);
+#endif
+
+       s->hashlink = (literalstring*) hashtable_string.ptr[slot];
+       s->string   = (java_object_t *) js;
+       hashtable_string.ptr[slot] = s;
+
+       /* update number of hashtable entries */
+
+       hashtable_string.entries++;
+
+       /* reorganization of hashtable */       
+
+       if (hashtable_string.entries > (hashtable_string.size * 2)) {
+               /* reorganization of hashtable, average length of the external
+                  chains is approx. 2 */
+
+               u4             i;
+               literalstring *s;
+               literalstring *nexts;
+               heapstring_t  *tmpjs;
+               hashtable      newhash;                          /* the new hashtable */
+      
+               /* create new hashtable, double the size */
+
+               hashtable_create(&newhash, hashtable_string.size * 2);
+               newhash.entries = hashtable_string.entries;
+      
+               /* transfer elements to new hashtable */
+
+               for (i = 0; i < hashtable_string.size; i++) {
+                       s = (literalstring*) hashtable_string.ptr[i];
+
+                       while (s) {
+                               nexts = s->hashlink;
+                               tmpjs = (heapstring_t *) s->string;
+                               slot  = unicode_hashkey(tmpjs->value->data, tmpjs->count) & (newhash.size - 1);
+         
+                               s->hashlink = (literalstring*) newhash.ptr[slot];
+                               newhash.ptr[slot] = s;
+       
+                               /* follow link in external hash chain */
+                               s = nexts;
+                       }
+               }
+       
+               /* dispose old table */
+
+               MFREE(hashtable_string.ptr, void*, hashtable_string.size);
+               hashtable_string = newhash;
+       }
+
+       LOCK_MONITOR_EXIT(lock_hashtable_string);
+
+       return (java_object_t *) js;
+}
+
+
+/* literalstring_new ***********************************************************
+
+   Creates a new literalstring with the text of the utf-symbol and inserts
+   it into the string hashtable.
+
+*******************************************************************************/
+
+java_object_t *literalstring_new(utf *u)
+{
+    char             *utf_ptr;       /* pointer to current unicode character  */
+                                        /* utf string                            */
+    u4                utflength;     /* length of utf-string if uncompressed  */
+    java_chararray_t *a;             /* u2-array constructed from utf string  */
+    u4                i;
+
+       utf_ptr = u->text;
+       utflength = utf_get_number_of_u2s(u);
+
+    /* allocate memory */ 
+    a = (java_chararray_t*) mem_alloc(sizeof(java_chararray_t) + sizeof(u2) * (utflength - 1) + 10);
+
+    /* convert utf-string to u2-array */
+    for (i = 0; i < utflength; i++)
+               a->data[i] = utf_nextu2(&utf_ptr);
+
+    return literalstring_u2(a, utflength, 0, false);
+}
+
+
+/* literalstring_free **********************************************************
+
+   Removes a literalstring from memory.
+
+*******************************************************************************/
+
+#if 0
+/* TWISTI This one is currently not used. */
+
+static void literalstring_free(java_object_t* string)
+{
+       heapstring_t     *s;
+       java_chararray_t *a;
+
+       s = (heapstring_t *) string;
+       a = s->value;
+
+       /* dispose memory of java.lang.String object */
+       FREE(s, heapstring_t);
+
+       /* dispose memory of java-characterarray */
+       FREE(a, sizeof(java_chararray_t) + sizeof(u2) * (a->header.size - 1)); /* +10 ?? */
+}
+#endif
+
+
+/* javastring_intern ***********************************************************
+
+   Intern the given Java string.
+
+   XXX NOTE: Literal Strings are direct references since they are not placed
+   onto the GC-Heap. That's why this function looks so "different".
+
+*******************************************************************************/
+
+java_handle_t *javastring_intern(java_handle_t *s)
+{
+       java_lang_String *so;
+       java_chararray_t *value;
+       int32_t           count;
+       int32_t           offset;
+/*     java_lang_String *o; */
+       java_object_t    *o; /* XXX see note above */
+
+       so = (java_lang_String *) s;
+
+       value  = LLNI_field_direct(so, value); /* XXX see note above */
+       LLNI_field_get_val(so, count, count);
+       LLNI_field_get_val(so, offset, offset);
+
+       o = literalstring_u2(value, count, offset, true);
+
+       return LLNI_WRAP(o); /* XXX see note above */
+}
+
+
+/* javastring_fprint ***********************************************************
+
+   Print the given Java string to the given stream.
+
+*******************************************************************************/
+
+void javastring_fprint(java_handle_t *s, FILE *stream)
+{
+       java_lang_String        *so;
+       java_handle_chararray_t *value;
+       int32_t                  count;
+       int32_t                  offset;
+       uint16_t                 c;
+       int                      i;
+
+       so = (java_lang_String *) s;
+
+       LLNI_field_get_ref(so, value, value);
+       LLNI_field_get_val(so, count, count);
+       LLNI_field_get_val(so, offset, offset);
+
+       for (i = offset; i < offset + count; i++) {
+               c = LLNI_array_direct(value, i);
+               fputc(c, stream);
+       }
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/vm/string.hpp b/src/vm/string.hpp
new file mode 100644 (file)
index 0000000..080c183
--- /dev/null
@@ -0,0 +1,114 @@
+/* src/vm/stringlocal.h - string header
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#ifndef _STRINGLOCAL_H
+#define _STRINGLOCAL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct literalstring literalstring;
+
+
+#include "config.h"
+
+#include "vmcore/system.h"
+
+#include "vm/types.h"
+
+#include "toolbox/hashtable.h"
+
+#include "vm/global.h"
+
+#include "vmcore/utf8.h"
+
+
+/* data structure of internal javastrings stored in global hashtable **********/
+
+struct literalstring {
+       literalstring     *hashlink;        /* link for external hash chain       */
+       java_object_t     *string;  
+};
+
+
+/* javastring-hashtable */
+extern hashtable hashtable_string;
+
+
+/* function prototypes ********************************************************/
+
+/* initialize string subsystem */
+bool string_init(void);
+
+void stringtable_update(void);
+
+/* creates a new object of type java/lang/String from a utf-text */
+java_handle_t *javastring_new(utf *text);
+
+/* creates a new object of type java/lang/String from a utf-text, changes slashes to dots */
+java_handle_t *javastring_new_slash_to_dot(utf *text);
+
+/* creates a new object of type java/lang/String from an ASCII c-string */
+java_handle_t *javastring_new_from_ascii(const char *text);
+
+/* creates a new object of type java/lang/String from UTF-8 */
+java_handle_t *javastring_new_from_utf_string(const char *utfstr);
+
+/* creates a new object of type java/lang/String from (possibly invalid) UTF-8 */
+java_handle_t *javastring_safe_new_from_utf8(const char *text);
+
+/* make c-string from a javastring (debugging) */
+char *javastring_tochar(java_handle_t *string);
+
+/* make utf symbol from javastring */
+utf *javastring_toutf(java_handle_t *string, bool isclassname);
+
+/* creates a new javastring with the text of the utf-symbol */
+java_object_t *literalstring_new(utf *u);
+
+java_handle_t *javastring_intern(java_handle_t *s);
+void           javastring_fprint(java_handle_t *s, FILE *stream);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _STRINGLOCAL_H */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/vm/stringlocal.h b/src/vm/stringlocal.h
deleted file mode 100644 (file)
index 080c183..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/* src/vm/stringlocal.h - string header
-
-   Copyright (C) 1996-2005, 2006, 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   This file is part of CACAO.
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2, or (at
-   your option) any later version.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-*/
-
-
-#ifndef _STRINGLOCAL_H
-#define _STRINGLOCAL_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct literalstring literalstring;
-
-
-#include "config.h"
-
-#include "vmcore/system.h"
-
-#include "vm/types.h"
-
-#include "toolbox/hashtable.h"
-
-#include "vm/global.h"
-
-#include "vmcore/utf8.h"
-
-
-/* data structure of internal javastrings stored in global hashtable **********/
-
-struct literalstring {
-       literalstring     *hashlink;        /* link for external hash chain       */
-       java_object_t     *string;  
-};
-
-
-/* javastring-hashtable */
-extern hashtable hashtable_string;
-
-
-/* function prototypes ********************************************************/
-
-/* initialize string subsystem */
-bool string_init(void);
-
-void stringtable_update(void);
-
-/* creates a new object of type java/lang/String from a utf-text */
-java_handle_t *javastring_new(utf *text);
-
-/* creates a new object of type java/lang/String from a utf-text, changes slashes to dots */
-java_handle_t *javastring_new_slash_to_dot(utf *text);
-
-/* creates a new object of type java/lang/String from an ASCII c-string */
-java_handle_t *javastring_new_from_ascii(const char *text);
-
-/* creates a new object of type java/lang/String from UTF-8 */
-java_handle_t *javastring_new_from_utf_string(const char *utfstr);
-
-/* creates a new object of type java/lang/String from (possibly invalid) UTF-8 */
-java_handle_t *javastring_safe_new_from_utf8(const char *text);
-
-/* make c-string from a javastring (debugging) */
-char *javastring_tochar(java_handle_t *string);
-
-/* make utf symbol from javastring */
-utf *javastring_toutf(java_handle_t *string, bool isclassname);
-
-/* creates a new javastring with the text of the utf-symbol */
-java_object_t *literalstring_new(utf *u);
-
-java_handle_t *javastring_intern(java_handle_t *s);
-void           javastring_fprint(java_handle_t *s, FILE *stream);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _STRINGLOCAL_H */
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
index beaf615da74017c9f096b77b7ec252c5452909c7..8eb20bb254e220ec2f05a4c0a9d6b3c569d83b62 100644 (file)
@@ -82,7 +82,7 @@
 #include "vm/primitive.hpp"
 #include "vm/properties.h"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vm/jit/argument.h"
index 6f7e583fc143e04927d31292cdfd408c239aa715..9f1dbe3339a063ff507ca5211fcab488f7493747 100644 (file)
@@ -46,7 +46,7 @@ typedef struct extra_classref extra_classref;
 #include "toolbox/list.h"
 
 #include "vm/global.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 
 #if defined(ENABLE_JAVASE)
 # include "vmcore/annotation.h"
index d1b5f42011a2409a5cd4f576a267d3b3e88e3410..59fe3bdf51cc5a89f2c3497c8eee16e33630beda 100644 (file)
@@ -40,7 +40,7 @@
 #include "vm/exceptions.hpp"
 #include "vm/global.h"
 #include "vm/primitive.hpp"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vmcore/annotation.h"
index c189fe00b64813e6296f73adca0c81490704a07b..fe3631a62c989f9664a70b1f2fc7dcce95e22eb2 100644 (file)
@@ -42,7 +42,7 @@
 #include "vm/array.h"
 #include "vm/exceptions.hpp"
 #include "vm/primitive.hpp"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vm/jit_interface.h"
index f4120fa770909840472635b3c0305bbd24db2b67..0fcb11ba7660dc4e84df9c1d78a7320f03b9ff56 100644 (file)
@@ -46,7 +46,7 @@
 #include "vm/package.hpp"
 #include "vm/primitive.hpp"
 #include "vm/resolve.h"
-#include "vm/stringlocal.h"
+#include "vm/string.hpp"
 #include "vm/vm.hpp"
 
 #include "vm/jit_interface.h"